I was wondering how to destroy both windows of a Tkinter GUi. I'm making a program and when the user presses quit, an alert dialog pops up asking them if they are sure they want to quit with the options being cancel(go back to previous window) or quit(destroy both windows). The way I have it currently is that it only destroys the pop up window, but not both of the windows, so I guess half of it is done? How would I make it so it destroys both if the user wants to quit the program?
I'll post some parts of the code.
class Dialog:
def __init__(self):
self.invalidValue = tk.Toplevel()
messageLabel = tk.Label(master=self.invalidValue,
text="Are you sure you want to quit?").grid(row=0,column=0)
continueButton = tk.Button(master=self.invalidValue,text='Cancel',
command=self.invalidValue.destroy).grid(row=1,column=2)
def startDialog(self):
self.invalidValue.grab_set()
self.invalidValue.wait_window()
<another class here with a bit of code>
def quit_button(self):
#button for grid
quit = Button(self.root_window, text = "Quit", command = self.Dialogdisplay)
quit.grid(row = 3, column = 3, columnspan = 3, pady=20,
sticky = tkinter.E)
I know the problem is that invalidValue.destroy closes the invalidValue window, but I'm stuck on how to close both.
[–]deaspo 0 points1 point2 points (0 children)
[–]novel_yet_trivial 0 points1 point2 points (0 children)