Python tkinter closes the previous toplevel when creating a new toplevel

problem description

just learned python GUI, using tkinter

when you use a button of Tk () to open a Toplevel , you can generally open it indefinitely. How to automatically close the toplevel before creating a new project?

my gui looks like this:

()

  1. button(),destroy(), Toplevel,button

  1. one way to realize automation is to check whether the focus is in this window. If not, destroy () , but don"t know how to do it. bind can only be used for controls
.
Jun.22,2022

resolved.
introducing global variables

  stackoverflow  

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36eaa-2c05b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36eaa-2c05b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?