I'm working on my very first python GUI, and I want to close all the previous windows from the code after clicking on the 'OK' button of the Message
messagebox.showinfo('Access Granted', 'Your data has been retrieved.')
The tkinter dialogs return a string representing what the user clicked on, so it's just a matter of saving that value and checking it afterwards. However, since showinfo
only gives the user one option it's always going to return "ok"
, so there's no need to check the value. Just call your function after the dialog has been displayed:
def some_function():
messagebox.showinfo('Access Granted', 'Your data has been retrieved.')
root.destroy()
...
button = tk.Button(root, text="Quit", command=some_function)