I have a master Frame (call it a
), and a popup Toplevel (call it b
). How do I make sure the user cannot click on anything in a
while b
is "alive"?
To disable all the widgets inside that particular frame, we have to select all the children widgets that are lying inside that frame using winfor_children() and change the state using state=('disabled' or 'enable') attribute.
In order to destroy the window we can use the destroy() callable method. However, to hide the Tkinter window, we generally use the “withdraw” method that can be invoked on the root window or the main window. In this example, we have created a text widget and a button “Quit” that will close the root window immediately.
To handle the window close event in Tkinter with Python, we call the root. protocol method with the 'WM_DELETE_WINDOW' event. to call root. protocole with "WM_DELETE_WINDOW" to add a close window handler.
Popup window in Tkinter can be created by defining the Toplevel(win) window. A Toplevel window manages to create a child window along with the parent window. It always opens above all the other windows defined in any application.
If you don't want to hide the root but just make sure the user can only interact with the popup, you can use grab_set()
and grab_release()
.
b.grab_set() # when you show the popup
# do stuff ...
b.grab_release() # to return to normal
Alternatively, you could withdraw()
the root to make it invisible:
a.withdraw()
will leave the root alive, but only b
visible.
If you need it back, you can do
a.deiconify()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With