1
我是tkinter的新手,並希望根據顯示的標誌進行UI操作。 基本上,我想關閉一個窗口,打開另一個窗口與當前狀態或刪除文本,並顯示與當前狀態的另一個文本。關閉tkinter的窗口
class App(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.start()
def callback(self):
self.root.quit()
def run(self):
self.root = tk.Tk()
self.root.protocol("WM_DELETE_WINDOW", self.callback)
label = tk.Label(self.root, text="Start Initialization")
label.pack()
self.root.mainloop()
class QQQ:
def quit(self):
self.delete(1.0,END)
class Appo(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.start()
def callback(self):
self.root.quit()
def run(self):
self.root = tk.Tk()
self.root.protocol("WM_DELETE_WINDOW", self.callback)
label = tk.Label(self.root, text="Initialization ended")
label.pack()
self.root.mainloop()
for i in range(100000):
time.sleep(0.5)
print(i)
if(i==1):
app = App()
time.sleep(1)
qqq=QQQ()
if(i==10):
app=Appo()
你的問題是什麼? (建議刪除代碼的雙倍間隔) –
在線程函數中,可以使用while循環並檢查可以在主線程中更改的條件。 – Dashadower
我正在考慮實時更改短信。 – CherChuan