How to close Tkinter TopLevel Windows
In this tutorial we will explore several different ways we can Close Tkinter TopLevel Windows. We will use a simple button, which triggers a destroy call to our TopLevel widget. Watch the video to see how its done!
Пікірлер: 6
Nice video.
i was using window.destroy which failed so after watching this I tried root.destroy and it worked!
thankkkkkkk youuuuuu
Thanks for this video. It's really helpful. If I want to use iconify or withdraw to hide the toplevel instance and later use deiconify to show that toplevel when needed. How can I do that without having an error when I close it and later try to reopen it. I want to leave the toplevel outside of the function so that I can access the 'e1' in other function. Here is an example: from tkinter import * root=Tk() window1=Toplevel() window1.iconify() e1=Entry(window1) def showScreen(): window1.deiconify() e1.pack() button1=Button(root, text='Show toplevel screen', command=showScreen) button1.pack() root.mainloop() Thanks for your help.
@coderslegacy5661
Жыл бұрын
When you close the TopLevel window, this makes the window1 reference invalid. As in, it no longer points to a TopLevel window. Hence why there is an error. The way you declared the windows here is wrong. If you want to access E1, then this can be done in a more proper manner. I advise you to watch this Video to learn how to better structure your Windows and learn how to access widgets across windows. kzread.info/dash/bejne/qXyZ0bmGZNvcYLg.html