pthom / imgui_bundle

Dear ImGui Bundle: an extensive set of Ready-to-use widgets and libraries, based on ImGui. Start your first app in 5 lines of code, or less. Whether you prefer Python or C++, this pack has your back!
https://pthom.github.io/imgui_bundle/
MIT License
667 stars 66 forks source link

With block / context manager support #154

Closed Aman-Anas closed 9 months ago

Aman-Anas commented 9 months ago

I recently switched over to using imgui_bundle in one of my projects and the python bindings from pyimgui, since imgui_bundle has a newer version of imgui as well as a more pythonic API in some places (for example, window and config flags). So far, it's been great and I was able to translate my backend by adapting the opengl backend examples, since they're so similar to pyimgui.

However, I was wondering if it would be possible to have with block (context manager) support in the future, similar to how pyimgui has support for initializing windows like

with imgui.begin("Name of Window"):
    # do stuff
    pass

Hopefully it's not too difficult to implement (maybe auto-generated for all begin/end blocks?), it would be a great feature.

Here's the relevant issue from pyimgui from mCoding https://github.com/pyimgui/pyimgui/issues/255

pthom commented 9 months ago

Hi,

Thanks for the suggestion, it is interesting! I implemented this in 34e692cc095c673483039b1b56f878d3f51ce435 It could not be auto-generated, neither could it replace the bindings in the imgui module. Instead, the imgui_ctx module provides those.

See demo