В настоящее время у меня есть функция, которая показывает новый экран (назовем его A), а затем выполняет обратный отсчет 10 секунд.Через 10 секунд пользователь переходит на новый экран (B).Я бы хотел, чтобы команда .after не выполнялась, если пользователь нажимает кнопку на экране «A» до истечения 10 секунд.
class MainGate3(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
background_image = tk.PhotoImage(file="Sylvanas.png") # Displays whats in the file
background_label = tk.Label(self, image=background_image) # Makes tk.Label display the background_image
background_label.place(x=0, y=0, relwidth=1, relheight=1) # Adjusts the height/width
background_label.image = background_image # Recognises the label as an image
def gate():
controller.show_frame("MainGate4")
button1.after(10000, lambda:controller.show_frame("MainMenu"))
button1 = tk.Button(self, text="Commence Battle", bg="black", fg="white", height=2, width=20,
command=gate)
button1.place(x="712", y="433")
class MainGate4(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
background_image = tk.PhotoImage(file="Sylvanas1.png") # Displays whats in the file
background_label = tk.Label(self, image=background_image) # Makes tk.Label display the background_image
background_label.place(x=0, y=0, relwidth=1, relheight=1) # Adjusts the height/width
background_label.image = background_image # Recognises the label as an image
button1 = tk.Button(self, text="Parry Right", bg="black", fg="white", height=2, width=20,
command=lambda: controller.show_frame("MainGate3"))
button2 = tk.Button(self, text="Parry Left", bg="black", fg="white", height=2, width=20,
command=lambda: controller.show_frame("MainGate3"))
button3 = tk.Button(self, text="Dodge", bg="black", fg="white", height=2, width=20,
command=lambda: controller.show_frame("MainGate3"))
button1.place(x="83", y="140")
button2.place(x="83", y="240")
button3.place(x="83", y="340")