Вы можете использовать self.update () в своем коде, чтобы появилось всплывающее окно.
import tkinter as tk
import time
class GUI(tk.Tk):
def __init__(self):
super().__init__()
self.button1 = tk.Button(text="Start", command=self.make_green)
self.button1.pack()
def popup(self):
tl = tk.Toplevel(self)
tl.transient()
tk.Label(tl, text="Painting green").pack()
self.update()
tl.grab_set()
return tl
def make_green(self):
wait_popup = self.popup()
time.sleep(10)
self.button1.config(bg="green")
wait_popup.destroy()
a = GUI()
a.mainloop()
Или вы можете использовать многопоточность.
Начните с импорта Thread из потока.
from threading import Thread
Затем создайте новый метод
def thread_it(self):
return Thread(target=self.make_green, daemon=True).start()
и обновите команду вашей кнопки
self.button1 = tk.Button(text="Start", command=self.thread_it)