python-3.x - 单击时如何禁用Tkinter按钮
问题描述
因此,我试图在单击时禁用按钮,因为我只需要执行一次操作,在这种情况下,打印(“单击按钮”)。我不希望用户再次单击该按钮。使用此代码:
board = tk.Tk()
game.geometry("200x200")
def click():
print("button clicked")
button["state"] = tk.DISABLED
button = tk.Button(board, text="click to disable", command=click).place(x=100, y=100)
board.mainloop()
我不断收到错误消息:TypeError:'NoneType' 对象不支持项目分配。
我在这里错过了什么吗?如何禁用此按钮?
解决方案
推荐阅读
- node.js - 将下拉选择的值发布到 nodejs
- push-notification - 如何以编程方式读取传入的 Chromium 网络推送通知?
- c# - 如何在 C# 中转换字典
- python - 为什么我使用 gramlin_python 的客户端实例得到“AttributeError:'NoneType'对象没有属性'处理器'”?
- sql - 如何使用spring boot中的触发器根据先前的值手动生成唯一代码
- python - 多线程请求并连接到 DataFrame
- python - 哪个python3返回全局python二进制而不是虚拟环境
- python - Traceback(最近一次调用最后一次):在 python 中
- java - 用括号括起来的对象
- swift - 在 macOS Monterey 及更高版本中检测 MacBook 缺口