DearPyGui
DearPyGui copied to clipboard
Viewport stuck after closing when executing blocking instructions afterwards on MacOS
OS : MacOS 12.1 Machine : MacBook Air (13-inch, Early 2015) 1,6 GHz Dual-Core Intel Core i5 Python : 3.10.1 DearPyGui : 1.3.1
import dearpygui.dearpygui as dpg
dpg.create_context()
dpg.create_viewport()
# here happens the DPG magic :)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
# Then I'd like the viewport to close and do something like
a = input() # this is what I name a "blocking instruction"
# but DPG won't close
On Windows it works with the render_loop method:
import dearpygui.dearpygui as dpg
dpg.create_context()
dpg.create_viewport()
# here happens the DPG magic :)
dpg.setup_dearpygui()
dpg.show_viewport()
while dpg.is_dearpygui_running():
dpg.render_dearpygui_frame()
else:
dpg.destroy_context()
a = input("enter something:")
Will check on this!
https://github.com/hoffstadt/DearPyGui/blob/03a804e84a7bd575562887a555b8d37a1ef4c764/DearPyGui/src/modules/dearpygui_commands.h#L2518 Maybe mvCleanupViewport needs to be called if running flag is cleared? I don't see anything that is testing this flag. All I could see was glfw's "should close" also clearing this flag.
I hope that helps. I may be mistaken though.
I too would like to close the viewport.
@hoffstadt This is not isolated to MacOS. I am running windows 10.
Related to this: on both macOS (12.2.1 on M1 Pro) and Windows (10 Enterprise 21H1 on Xeon), if you create another context and viewport immediately after destroying one, the first viewport doesn't close until the second context is destroyed (I appreciate this is possibly a bad design though!):
import dearpygui.dearpygui as dpg
def temporary_viewport(lifetime_in_frames: int) -> None:
dpg.create_context()
dpg.create_viewport(title="Test", width=800, height=340)
with dpg.window(label="Test", tag="Test"):
dpg.add_text(f"Lifetime of this viewport should be {lifetime_in_frames} frames")
dpg.setup_dearpygui()
dpg.show_viewport()
frame_count = 0
while dpg.is_dearpygui_running():
frame_count += 1
if frame_count > lifetime_in_frames:
dpg.stop_dearpygui()
dpg.destroy_context()
break
dpg.render_dearpygui_frame()
print("Done")
if __name__ == "__main__":
temporary_viewport(lifetime_in_frames=60) # blocks for 60 frames
# would expect first viewport to disappear here
temporary_viewport(lifetime_in_frames=600) # but now we end up with two viewports
# and both of them disappear after a further 600 frames
Issue for an old version of DPG. Closing.