【发布时间】:2017-04-30 11:19:46
【问题描述】:
我希望能够在按下按钮时更改标签的背景颜色。我目前有以下代码。
def violet_btn():
bg = 'violet'
def violet_label():
if violet_btn == True:
color = 'violet'
else:
color = 'grey'
violet_l = Label(the_window, bg = 'grey', height= 1, width = 8)
violet_l.grid(row=1, column=1, padx=5, pady=3)
violet = Button(the_window, text = 'Violet', height= 1, width = 8, command = violet_label)
violet.grid(row=2, column=1, padx=5, pady=3)
我知道它不够复杂,但我是 python 新手,不知道还要添加什么
【问题讨论】:
标签: python python-2.7 tkinter