Я пытаюсь добавить кнопку к этому кадру (показанному во втором последнем абзаце кода) на Python Tkinter после завершения обратного отсчета . На этом этапе кнопка будет отображаться, но не будет выполняться до следующего кадра (определенного ранее, код не отображается как WorkoutsPage). Буду признателен за любую помощь .. Спасибо
def __init__(self, master):
tk.Frame.__init__(self, master)
tk.Frame.configure(self)
tk.Label(self, text="SQUATS", bg = '#44d7b6', width=50, height=2, font=('PT Sans', 18, "bold"), foreground = 'white').pack(side="top", fill='x', pady=5)
tk.Button(self, text="QUIT", font=('PT Sans', 12, "bold"),
command=lambda: master.switch_frame(WorkoutsPage)).pack()
tk.Label(self, text="").pack()
## Creates a blank text line
self.label = tk.Label(self, text="")
## Creates the countdown as a label
self.label.pack()
## The above code can be used to make the countdown look different (for TK)
self.remaining = 0
## Defines '0' as the last number of the count down
self.countdown(8)
## Defines the countdown to '5' seconds
def countdown(self, remaining = None):
if remaining is not None:
## Defines what the countdown will do if the time is not finished
self.remaining = remaining
## Displays time left
if self.remaining <= 0:
self.label.configure(text="Workout Completed!")
tk.Label(self, text="You have been awarded 10 points for completing Squats!").pack()
## As the countdown hits '0' the label will be configured to display the above.
tk.Button(self, text="Finish Workout", font=('PT Sans', 12, "bold"),
command=lambda: master.switch_frame(WorkoutsPage)).pack()
else:
self.label.configure(text="%d" % self.remaining + " Seconds Left!", font=('PT Sans', 14, "bold"))
## Displays the format of the countdown
self.remaining = self.remaining - 1
## Sets the number displayed to be (value -1)
self.after(1000, self.countdown)
## Sets the time on countdown to change after 1 second