pyimgui / pyimgui

Cython-based Python bindings for dear imgui
https://pyimgui.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.31k stars 181 forks source link

For loop on imgui button callback function #231

Open luisarandas opened 3 years ago

luisarandas commented 3 years ago

Hello all!

I am currently generating some image data and drawing it to an imgui.image object. I am trying to do this multiple times, say 100 images at once and drawing them realtime, though I came across a loop problem. I have:

if (imgui.button("Button 1")): textures.generate() gl_stuff... imgui.image(texture, w, h)

Calling the specified function in the button overwrites global code variables that are the PIL image and its decoded data for a gl.glTexImage2D object. Since all of this is in the main() function, I have no problem in drawing them one button click at the time. But when I do a for loop inside it - either in the button callback or in the textures.generate() function it only draws one to the imgui.image after all the images are generated. It prints all of them in the terminal but only the last one is generated, as the code was for a bit interrupted while the button for loop isn't finished.

Any way to go around this? Thanks

learn-more commented 2 years ago

Unfortunately, judging by the lack of comments on this question it seems that your problem was not described in a way that allows others to help you. Would it be possible for you to share a minimal, reproducible example that better showcases your problem?