什么是我可以在 Tkinter 中为标签的背景在两种颜色之间实现淡入淡出的方法?我希望计时器标签的颜色在倒计时时改变。这些是我目前正在使用的片段(以澄清我在做什么)。
…
labelcolor = "#%02x%02x%02x" % (0, 0, 0)
…
def pomodoro(self, remaining = None):
self.button.configure(state=tk.DISABLED)
self.labelcolor = "#%02x%02x%02x" % (200, 32, 32)
self.label.configure(bg = self.labelcolor)
if remaining is not None:
self.remaining = remaining
if self.remaining <= 0:
self.label.configure(text="Time's up!")
self.breakcommand
else:
self.label.configure(text= time.strftime('%M:%S', time.gmtime(self.remaining))) #Integer to 'Minutes' and 'Seconds'
self.remaining = self.remaining - 1
self.after(1000, self.pomodoro)
…
self.label = tk.Label(self, text="Pick One", width=12, font="Helvetica 32", fg = "white", bg = self.labelcolor )
…