这很难解释,所以我会尽力而为。
我有一个主程序窗口,其中有一个名为“备份/恢复”的按钮。按下此按钮会打开一个新窗口,其中有两个按钮可供选择;“备份还原”。按下其中任何一个按钮都会打开第三个窗口,其中包含有关执行操作的信息。当我第一次运行“备份”或“恢复”时,一切都很好。如果我关闭带有两个按钮的第二个窗口;然后从主窗口按“备份/恢复”按钮,它会带回带有两个按钮的第二个窗口,但单击时标有“备份”和“恢复”的按钮什么也不做。第三个窗口上的按钮只有在第二个窗口关闭一次后才会失去其功能。
创建窗口时,我使用以下代码:
def exportEFS(self): #this is the second window with two buttons
self.exportGUI = Toplevel()
Button(self.exportGUI, text='Backup', command=self.backup).pack(padx=100,pady=5)
Button(self.exportGUI, text='Restore', command=self.restore).pack(padx=100,pady=5
def backup(self): #this is the backup window that does not work if the second window has
been closed once.
self.backup = Toplevel()
<button code>
def restore(self): #this is the backup window that does not work if the second window has
been closed once.
self.restore = Toplevel()
<button code>
主窗口的代码太大而无法发布,我不确定是否有任何部分有帮助。