我如何 运行 函数后的代码 root.destroy

how can i run a code after the function root.destroy

你好,我正在使用 tkinter 开发 python,我想 运行 一个 window(在 Main 中)在销毁 Login [= 中的第一个 window 之后21=] ,但问题是代码停在 root.destroy 并且不执行代码的 reste

我尝试用 root.qui() 替换 root.destroy() ,其余代码继续执行但第一个 window 仍然出现

from tkinter import *
import threading

class Login:
    def __init__(self):
        self.window=Tk()
        self.window.geometry("600x500+50+50")
        self.window.resizable(False,False)
        self.window.configure(bg="#fafafa")

    def start(self):
        self.window.mainloop()

    def stop(self):
        self.window.destroy()


class Main: 
    def __init__(self):
        self.login=Login()


   def test(self):
        a=input("a : ")
        b=input("b : ")

        if a ==b:
            self.login.stop()
        print("window destroyed .....")

test=Main()
threading.Thread(target=test.test).start()
test.login.start()

最后我找到了解决问题的方法,方法是 login.stop()

我将指令 window.destroy() 替换为 window.after(0,window.destroy)