我在Python中从Tkinter收到奇怪的错误

时间:2018-11-01 19:33:15

标签: python tkinter

我正在尝试创建一个tkinter项目,但是当我试图像第三次那样运行时,它给了我这个错误:

Traceback (most recent call last):
File "/Users/cool/Documents/STM Wisepay Service.py", line 63, in <module> 
  app = App(root)
File "/Users/cool/Documents/STM Wisepay Service.py", line 20, in __init__
  self.create_buttons()  
File "/Users/cool/Documents/STM Wisepay Service.py", line 30, in create_buttons
  tk.Button(button_frame, text = "Add to Debt", commmand = self.debt).grid(column = 6, row = 5)  
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tkinter/__init__.py", line 2366, in __init__
  Widget.__init__(self, master, 'button', cnf, kw  
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tkinter/__init__.py", line 2296, in __init__
  (widgetName, self._w) + extra + self._options(cnf)
_tkinter.TclError: unknown option "-commmand"

该如何解决?我的代码有什么问题?

这是我的代码: https://pastebin.com/mWPEFbpz

1 个答案:

答案 0 :(得分:2)

您的拼写命令错误(三分)

您正在向它传递一个名为commmand的变量,它不知道如何使用该变量。

tk.Button(... commmand = ...

您可以在此处的错误消息中看到它

_tkinter.TclError: unknown option "-commmand"

这些python错误消息实际上非常有帮助。我鼓励您仔细阅读它们,以了解诸如此类的内容。