0

I am very new to using python and tkinter in general, but I was hoping to get some guidance on how to handle toplevel pop up exits. I have wrote a pop up that once would disable a button in the root level unless all the checkboxes in the pop up window are checked, and the close button is clicked.

However, I was wondering if there was a way to handle users "X-ing out" (closing via clicking the x icon top right corner of pop ups) instead of closing the pop via the button I made. (The button has the command .destroy() and handles toggling the status of the button on root level).

KSmith
  • 57
  • 1
  • 7
pixxelate
  • 3
  • 1
  • To clarify, you want to prevent the user from being able to close your toplevel window with the X button? Is that what you are asking? You could definitely handle that and prevent the window from closing until they address your conditions. Something like `self.protocol("WM_DELETE_WINDOW", your_function)` where `your_function` would manage what happens when they try to close it with the X button. – Rory Jun 09 '22 at 15:53
  • @Rory Thank you so much for your reply, this actually answered the question for me I just simply did not know the `self.protocol("WM_DELETE_WINDOW", your_function)` part this is allowing me to handle the event perfectly. Thank you!!! – pixxelate Jun 09 '22 at 17:01

0 Answers0