I am trying to restart my main GUI/Halt the program flow when I Click on the "X" button in my tkinter messagebox . Any idea how can I do this ?
PS: I have read the many threads about closing the main GUI itself but nothing specific to messagebox
By default , my code proceeds to ask me for an output path using the filedailog.askdirectory() method when clicking "ok", or on closing the messagebox
There's no simple way to add a custom handler to the "X" button. I think it's better to use
messagebox.askokcancel()variation of messageboxes instead ofshowinfo, and halt the program if the returned result is False:Or, even simpler, you can just show
filedialog.askdirectory()directly. If the user doesn't want to choose directory, they can click on the "Cancel" button, and then the program checks if there was empty value returned, and halts if so: