-
-
Notifications
You must be signed in to change notification settings - Fork 695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Window freezes when using stop_dearpygui #2013
Comments
I found a work around for displaying the alert boxes I need by moving |
Try this workaround: import ctypes
import os
from ctypes.wintypes import HWND, LPARAM, BOOL
import dearpygui.dearpygui as dpg
WM_CLOSE = 16
WNDENUMPROC = ctypes.WINFUNCTYPE(HWND,
BOOL,
LPARAM)
def get_hwnd_from_pid(pid: int) -> int | None:
result = None
def callback(hwnd, _):
nonlocal result
cpid = ctypes.c_ulong()
ctypes.windll.user32.GetWindowThreadProcessId(hwnd, ctypes.byref(cpid))
cpid = cpid.value
if cpid == pid:
result = hwnd
return False
return True
cb_worker = WNDENUMPROC(callback)
ctypes.windll.user32.EnumWindows(cb_worker, 0)
return result
def destroy():
hwnd = get_hwnd_from_pid(os.getpid())
ctypes.windll.user32.SendMessageW(hwnd, WM_CLOSE, 0, 0)
dpg.create_context()
dpg.create_viewport()
dpg.setup_dearpygui()
with dpg.window(label="Example Window"):
dpg.add_button(label="EXIT", callback=destroy)
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
import time
print("Starting sleeping")
time.sleep(10)
print("Done sleeping") |
That works great, thank you for the help! |
I'm not certain whether def destroy():
dpg.stop_dearpygui()
dpg.destroy_context() The cursor buffers, then the viewport closes in about half a second (this even happens when |
Interesting, I seem to get slightly different results from my code when I play around with where those 2 commands are run... but thanks for that info, I think with some clever placements I can make it work how I want |
I think this is still a valid issue. import time
import dearpygui.dearpygui as dpg
dpg.create_context()
dpg.create_viewport(width=600, height=600)
dpg.setup_dearpygui()
with dpg.window(label="Test") as wnd:
dpg.add_button(label="Exit", callback=lambda: dpg.stop_dearpygui())
dpg.show_viewport()
dpg.start_dearpygui()
print("Exited from start_dearpygui")
time.sleep(3)
print("Before destroy_context")
dpg.destroy_context()
print("After destroy_context")
time.sleep(3)
print("Quit") If you run this on Windows, clicking the Exit button does not close the window; neither does it close when This is important: Inside of DPG, there is a function named Shouldn't |
Having this issue as well. |
#2275 will fix it. |
Version of Dear PyGui
Version: 1.8.0
Operating System: Windows 11
My Issue/Question
When using the method
dpg.stop_dearpygui()
the application wont begin to close until all code is finished running in the script.To Reproduce
Steps to reproduce the behavior:
time.sleep(10)
command is completed. (Specifically that the loading mouse icon doesnt even begin until thetime.sleep(10)
is finished.Expected behavior
I would expect the window to close before executing the code, as this prevents me from using any alert boxes in the remaining parts of my script
Screenshots/Video
Can provide if needed
Standalone, minimal, complete and verifiable example
The text was updated successfully, but these errors were encountered: