Comments (3)
I have added this to 0.0.1 milestone to ensure that we make a decision about this feature before we will ship first official release.
from pyimgui.
I have realised that using keyword-only arguments here is not a good solution:
- it will force users to use excessively verbose function calls
- it would have to either affect all arguments with default values or be very inconsistent
The best if we could keep the core Python API as close to C++ API as possible. This is already the first reason why I have proposed this InOutABC
interface. Forcing users to use keyword-only arguments will make a lot harder to port C++ examples to Python.
Fortunately I have found a simple way to handle both inout args and kwargs in a form of suggested decorator. Here is the modified code:
def allow_inout(arg_pos, kwarg_name, result_pos=1):
def wrapper(func):
@wraps(func)
def wrapped(*args, **kwargs):
try:
kwarg = args[arg_pos]
args = args[:arg_pos] + args[arg_pos+1:]
except IndexError:
kwarg = kwargs.get(kwarg_name, None)
inout_mode = isinstance(kwarg, InOutABC)
if inout_mode:
kwargs[kwarg_name]=kwarg.get()
result_tuple = func(*args, **kwargs)
if inout_mode:
kwarg.set(result_tuple[result_pos])
return result_tuple
return wrapped
return wrapper
I still need to reconsider if maybe it would be better to handle inout kwargs explicitly in every such function. Explicit inout handling will be less expensive in terms of performance but would require more code changes and maintenance. We need to decide what is more important: more expressive and shorter code or code that executes faster.
Anyway, such change does not have to be backwards incompatible so we don't have to make any decision before the first release. I move this feature to next milestone.
from pyimgui.
I did some experiments in feature/8-inout-arguments branch and it doesn't seem to be as straightforward as I initially thought. I'm moving this to next milestone because I want to finally release 1.0.0
from pyimgui.
Related Issues (20)
- -- deleted --
- Doesn't expose ImGuiStyle::ScaleAllSizes HOT 1
- Showing input text without a label HOT 1
- Documentation left side nav not scrollable
- Can't use it and i don't know why.
- "Game Insert"
- type stubs for pyimgui HOT 4
- None of the custom renderers change mouse cursor HOT 4
- default theme font HOT 4
- Loading SVGs as viewport/texture HOT 2
- [Bug}: When using pyimgui some users of my program have `GLError`s HOT 8
- Imgui port to pygame do not suport colaboration with programable opengl pipline
- Windows: Failed building wheel for imgui (from VsDevShell) HOT 5
- Example not working HOT 1
- pyimgui equivalent of ImGuiKey_NamedKey_END HOT 1
- Overflow error when using opengl, doublebuf and fullscreen HOT 1
- ImGui crashing when using OpenGL context 3.2+ even though GPU and driver support 4.6
- Upgrading dear imgui version beyond 1.82 HOT 6
- Anyone studied if F3D is able to render on pyimgui HOT 4
- I have a problem when i trying to use imgui[glfw] io.fonts.get_glyph_ranges_chinese_full() HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyimgui.