Skip to content

Behavior of show_viewport() & is_dearpygui_running() after closing the viewport #2619

@Atlamillias

Description

@Atlamillias

DearPyGui v2.2
Python v3.14
Windows 11

On Windows, closing the viewport window sets GContext->running to false via mvContext::StopRendering(). is_dearpygui_running() simply returns the result of GContext->running, so it makes sense that it returns False after closing the viewport. mvHandleMsg() destroys the viewport on close (I think), but calling show_viewport() will display the viewport again. Doing so does not update GContext->running, so any code that checks against it will fail e.g. split_frame(). Everything else seems to work as it should. This can be reproduced with a debugger and some bare-bones code:

from dearpygui import dearpygui as dpg

dpg.create_context()
dpg.setup_dearpygui()
dpg.create_viewport()
dpg.show_viewport()

while True: 
    dpg.render_dearpygui_frame()

The while-loop condition does not check is_dearpygui_running() and will to run after closing the viewport. Once the viewport is closed, set a breakpoint within the render loop and call show_viewport(). This can be done repeatedly in the same thread.
(Side node: After closing the viewport at least once, calling show_viewport() while the viewport is already displayed creates a "dead" viewport window.)

This behavior isn't documented and might be limited to Windows. However, I can easily see it being useful to display the viewport again once it's been closed. In its current state, many things appear to continue functioning properly, but it may have less-obvious side-effects (I don't have enough knowledge regarding DearPyGui's internals to say for certain). This issue is mostly just to make the behavior known.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions