【发布时间】:2012-05-16 22:13:41
【问题描述】:
我可以在 Tkinter 中为标签的背景在两种颜色之间实现淡入淡出的方法是什么? 我希望我的计时器标签的颜色在倒计时时改变。这些是我目前正在使用的 sn-ps,(以澄清我在做什么)。
…
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 )
…
【问题讨论】:
-
你对这个问题有什么不明白的地方?不知道如何更改标签的背景颜色,或者不知道如何创建颜色范围,或者还有其他不明白的地方?
-
@Bryan 我不明白如何从数学的角度进行自身的褪色,并从那里创建一个可用的函数,用于基于计时器在任何两种颜色之间进行褪色。抱歉我的问题不清楚。