【发布时间】:2018-03-13 00:04:21
【问题描述】:
假设我有一个按钮,button = Button(root, text="Hello", command = somecommand),如果某些条件在程序中为真,我想禁用它。这是我的代码:
from tkinter import *
root=Tk()
def hi():
print("hi")
button=Button(root,text="Say hello",command=hi)
button.pack()
while 1:
root.update_idletasks()
root.update()
if 1==1:
#disable button here
谢谢!
【问题讨论】:
-
您对此进行过研究吗?修改小部件属性的能力有据可查。