假设我有一个按钮,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
谢谢!在
将此reference作为书签(不完美,但非常有用)。Button page表示“state:将此选项设置为”tk禁用使按钮变灰并使其无响应。有价值tk.激活当鼠标在上面的时候。默认为tk.正常. ". 换句话说,}将取消激活并恢复{}。在
button['state'] = DISABLED
和{相关问题 更多 >
编程相关推荐