May-17-2020, 07:19 AM
(This post was last modified: May-17-2020, 07:59 AM by scratchmyhead.)
I was just wondering if there is a way to close all open windows upon program exit?
[Tkinter] How to close all windows when exit program
|
May-17-2020, 07:19 AM
(This post was last modified: May-17-2020, 07:59 AM by scratchmyhead.)
I was just wondering if there is a way to close all open windows upon program exit?
May-17-2020, 07:46 AM
If they are all toplevel windows of your root window, closing root window should close all
I welcome all feedback.
The only dumb question, is one that doesn't get asked. My Github How to post code using bbtags
May-17-2020, 07:48 AM
(This post was last modified: May-17-2020, 07:53 AM by scratchmyhead.)
But I have a self.root window that is still open when I close the main program.
class App(): def __init__(self): self.root = tk.Tk() self.label = Label(text="") self.label.pack() self.update_clock() self.root.mainloop() def update_clock(self): now = time.strftime("%H:%M:%S") #self.label.configure(text=now) # Put Arrivals in box=============================================================== arrivallb.delete(0, END) now = dt.datetime.now() dte = now.strftime("%m-%d-%Y") conn = sqlite3.connect('reservation.db') c = conn.cursor() c.execute("SELECT * FROM reserve") records = c.fetchall() for record in records: if record[22] != "*":
May-17-2020, 08:19 AM
The mai program should be the only root window all else can be toplevel windows (new windows that open up). Just my opinion. When the main root is closed all toplevel windows should close with it.
Some reading links https://python-tricks.com/toplevel-in-tkinter/ https://www.tutorialspoint.com/python/tk_toplevel.htm https://riptutorial.com/tkinter/example/...d-toplevel
I welcome all feedback.
The only dumb question, is one that doesn't get asked. My Github How to post code using bbtags |
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
[Tkinter] Noob question:Using pyttsx3 with tkinter causes program to stop and close, any ideas? | Osman_P | 4 | 5,375 |
Nov-14-2020, 10:51 AM Last Post: Osman_P |
|
[Tkinter] Program with Multiple Windows - how to use Class: | Riddle | 1 | 3,011 |
Apr-09-2020, 08:30 PM Last Post: Riddle |
|
How to close one of the windows in Tkinter | scratchmyhead | 3 | 4,862 |
Dec-21-2019, 06:48 PM Last Post: pashaliski |
|
Program strange behavior ( windows doesn't close) | adam2020 | 2 | 2,241 |
May-12-2019, 09:19 PM Last Post: adam2020 |
|
[PyQt] Close program using Push Button with the help of input from a Message Box | bhargavbn | 2 | 6,736 |
Oct-30-2018, 05:09 AM Last Post: bhargavbn |
|
[Tkinter] How to exit when multiple root windows. | weatherman | 4 | 5,544 |
May-10-2018, 11:52 PM Last Post: Larz60+ |
|
OnExit closes windows, but dosen't exit application | Larz60+ | 3 | 4,833 |
Sep-23-2017, 06:12 PM Last Post: snippsat |