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

The program doen't close without using Task Manager #11

Open
CezarGab opened this issue Jun 2, 2024 · 1 comment
Open

The program doen't close without using Task Manager #11

CezarGab opened this issue Jun 2, 2024 · 1 comment

Comments

@CezarGab
Copy link
Owner

CezarGab commented Jun 2, 2024

          NOTE: The program doen't close. You have to go to the task manager to end task since an error apperars with a label error which when you click ok doen't actually terminate the program. So a `os._exit(1)` function on exit must be implemented.

Originally posted by @xtho25 in #7 (comment)

I'll think about the best solution to implement. Perhaps a simple “x” in the top left corner.

@xtho25
Copy link
Contributor

xtho25 commented Jun 2, 2024

So i actually coded a solution to this many days ago but just forgot to post it. It's not perfect but it works. Basically you have to click on the widget for it to get recognised by windows and show the app in the taskbar and then you can just click on the x button to close it.

This works using overlay_root.protocol("WM_DELETE_WINDOW", on_close) to customise what happens when the x button gets clicked. From there it's as simple as making the on_close function which should look something like this:

def on_close():
    close = messagebox.askokcancel("Close", "Would you like to close the program?")
    if close:
        overlay_root.destroy()
        os._exit(1)

I also added a custom messagebox to give a warning to the user which is entirely optional and doen't really need to exist.
The reason why i dislike this option (and didn't make a pull request) is because initially you have to click on the window to get it recognised. The tk button by itself isn't a good option because if someone tries to click on the windows x button (using the taskbar and not the tk button) will cause the same issue of the window closing while leaving the program on. I believe that a small x button that can be turned on and off by a constant or an external config file paired with the code above can lead to a great solution.
(ok wow that took too much time to write)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants