Skip to content
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

destroy_context doesn't clean up the window #2173

Closed
PhilippThoelke opened this issue Sep 10, 2023 · 15 comments · Fixed by #2275
Closed

destroy_context doesn't clean up the window #2173

PhilippThoelke opened this issue Sep 10, 2023 · 15 comments · Fixed by #2275
Labels
state: pending not addressed yet type: bug bug

Comments

@PhilippThoelke
Copy link

PhilippThoelke commented Sep 10, 2023

Version of Dear PyGui

Version: 1.9.1
Operating System: Ubuntu 22.04 (KDE Plasma 5.27.7)

My Issue

Calling dpg.destroy_context() doesn't close the window, but just makes it unresponsive.
This seems like a very basic thing, so maybe there's something wrong with my OS or window manager? It works as expected on my Windows 11 system.
I also tried a range of DPG versions, all of them have the same issue on my Linux system.

To Reproduce

Run the code below and simply close the window by clicking on the x. The window doesn't close but just becomes unresponsive. It does unblock dpg.start_dearpygui(), calls destroy_context and goes into the while True loop as expected.

image

Expected behavior

The window should close properly.

Standalone, minimal, complete and verifiable example

import dearpygui.dearpygui as dpg

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

with dpg.window(label="tutorial"):
    dpg.add_text("Hello world")

dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()

print("window closed")

while True:
    pass
@PhilippThoelke PhilippThoelke added state: pending not addressed yet type: bug bug labels Sep 10, 2023
@v-ein
Copy link
Contributor

v-ein commented Sep 10, 2023

Probably Linux-only (with the minimal example given), because on Windows you can only get to print("window closed") by closing the window 🤣

@v-ein
Copy link
Contributor

v-ein commented Sep 10, 2023

Here's a modified example that will show somewhat similar behavior on Windows:

import dearpygui.dearpygui as dpg

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

with dpg.window(label="tutorial"):
    dpg.add_text("Hello world")
    dpg.add_button(label="Exit", callback=lambda: dpg.stop_dearpygui())

dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()

print("window closed")

while True:
    pass

Instead of closing the window, press Exit - and you'll get an unresponsive window.

@v-ein
Copy link
Contributor

v-ein commented Sep 10, 2023

Also, this is most probably a duplicate of #2013 - see my comment in that issue.

@v-ein
Copy link
Contributor

v-ein commented Sep 10, 2023

Also, there's a discussion in #1593 which shows how old the issue is! 😂

@PhilippThoelke
Copy link
Author

Ah, sorry for the duplicate, moving to #2013.

@v-ein
Copy link
Contributor

v-ein commented Sep 10, 2023

I'd like to point out that both #2013 and #1593 are closed - but not fixed. Let's leave at least one issue open ;)

@PhilippThoelke
Copy link
Author

PhilippThoelke commented Sep 10, 2023

Alright, since I can't reopen the other issues I'll stay here :D

Any plans on addressing this issue? If you are sure that mvCleanupViewport provides the intended functionality I could look into adding it to destroy_context(), if you think that makes sense.

@v-ein
Copy link
Contributor

v-ein commented Sep 10, 2023

I'm not sure how to fix this issue properly - it's up to @hoffstadt to decide... It might well be that mvCleanupViewport needs some rework. Unfortunately I don't have spare time at the moment to play with mvCleanupViewport. Maybe later.

@artelse
Copy link

artelse commented Nov 13, 2023

Having the same issue on POPOS with SwayWM. I have to kill the python process to close the viewport. Is there a way around this? For now this is a showstopper for me to use dpg!

@v-ein
Copy link
Contributor

v-ein commented Nov 14, 2023

On Windows, you could use WinAPI wrappers to close your window directly. I don't know if such a package exists on Linux - basically you need some kind of a SwayWM or Wayland API. Google says there's PyWayland, at least.

This would make your code platform-dependent, but with this kind of issues there's no cross-platform workarounds.

@artelse
Copy link

artelse commented Nov 14, 2023

Other GUI frameworks I tried don't have this problem and am unsure if this is wayland related, more seems like a bug or oversight.

@v-ein
Copy link
Contributor

v-ein commented Nov 14, 2023

It's a bug in DPG, just like I said in a comment in another ticket.

I'm talking about Wayland because you can use its API to forcefully close the window - as a workaround for the DPG bug. DPG does not close the window itself. Most users don't see it because their programs end immediately after dpg.destroy_context().

@v-ein
Copy link
Contributor

v-ein commented Nov 14, 2023

As an option, use dpg.minimize_viewport before destroy_context to get the unresponsive window out of view. Only if your program ends in a reasonably short time after that (so that the user doesn't try to restore the minimized window).

@Tanmay-R-Choudhary
Copy link

Any update on this?

@v-ein
Copy link
Contributor

v-ein commented Jun 21, 2024

PR #2275 is going to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: pending not addressed yet type: bug bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants