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

custom background in python doesn't work #147

Closed ShaiAvr closed 10 months ago

ShaiAvr commented 10 months ago

I am new to this library, but it seems promising for my needs. I want to render a 3D simulation with OpenGL and add ImGUI on top of it. The demo_custom_background.py looked exactly like what I needed, so I copied it and tried to run it, but I got an error:

Traceback (most recent call last):
  File "D:\dev\python\playground\glfw_demo.py", line 670, in <module>
    sys.exit(main())
             ^^^^^^
  File "D:\dev\python\playground\glfw_demo.py", line 659, in main
    runner_params.callbacks.custom_background = lambda: custom_background(app_state)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'imgui_bundle._imgui_bundle.hello_imgui.RunnerCallbacks' object has no attribute 'custom_background'

So, runner_params.callbacks.custom_background doesn't work anymore? How can I make this example run, or find another example for custom OpenGL rendering with ImGUI on top of it?

pthom commented 10 months ago

I’m In the process of integrating this in python. Give me a few days

ShaiAvr commented 10 months ago

Sounds awesome. Can’t wait to see it implemented.

district10 commented 10 months ago

πŸ‘ Expecting imgui_bundle + vtk (vedo or vispy) as an alternative to open3d (GUI part) or pypangolin.

ShaiAvr commented 10 months ago

At the moment, the only way to use OpenGL rendering is to use an explicit backend like GLFW and not ImmApp or hello_imgui, right?

pthom commented 10 months ago

@ShaiAvr @district10 : The callback custom_background is now available in python.

However, the update was not deployed to pypi yet, so you need to compile imgui_bundle from source:

See instructions here: https://pthom.github.io/imgui_bundle/install-instructions.html

TLDR:

git clone https://github.com/pthom/imgui_bundle.git
cd imgui_bundle
pip install -v .       # this will require a few minutes 
district10 commented 10 months ago

image

works for me. 😎 πŸ‘

ShaiAvr commented 10 months ago

Nice. I think I'll use GLFW manually like in imgui_example_glfw_opengl3.py. It will give me more control if I want to do advanced things in the future and I won't depend on immapp or hello_imgui. Not that I have anything against those libraries: they're amazing for quickly making fully functional applications. Keep up this amazing work 😊.

pthom commented 10 months ago

Nice.

Thanks!

I think I'll use GLFW manually like in imgui_example_glfw_opengl3.py. It will give me more control if I want to do advanced things in the future and I won't depend on immapp or hello_imgui.

Just remember that in this case you may have to implement support for HighDPI (depending on your target platform).