How to lock tkinter button after pressing on it

徘徊边缘 提交于 2021-01-29 04:29:23

问题


how to lock the button after pressing on it, until the other button is pressed or until I closed the program interface?


回答1:


I'm not sure what you mean by locking the button, I think you mean disabling. Disabling is just you not being able to click the button until you define the state back to 'normal'

Here is some sample code:

from Tkinter import *

def doDisable():
    b2.configure(state=DISABLED)

root = Tk()
b2 = Button(root, text="Disable button", command=doDisable)
b2.pack()
root.mainloop()


来源:https://stackoverflow.com/questions/36906182/how-to-lock-tkinter-button-after-pressing-on-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!