_tkinter.TclError:未知选项

时间:2017-10-14 10:11:18

标签: python user-interface tkinter

我目前正在尝试为学校项目创建一个地址簿GUI。目前我正在尝试将我的验证链接到GUI,但不断收到此错误消息:

Traceback (most recent call last):
File "C:\Users\katie_000\Downloads\GUI adresses practice (1).py", line 198,  in <module>
B = Button(window, width=46, text = "Add",fg="gray16", command=name())
File "C:\Users\katie_000\Downloads\GUI adresses practice (1).py", line 8, in name
Sname()
File "C:\Users\katie_000\Downloads\GUI adresses practice (1).py", line 17, in Sname
Hphone()
File "C:\Users\katie_000\Downloads\GUI adresses practice (1).py", line 24, in Hphone
label.configure("You must enter a phone number")
File "C:\Users\katie_000\AppData\Local\Programs\Python\Python36  \lib\tkinter\__init__.py", line 1479, in configure
return self._configure('configure', cnf, kw)
File "C:\Users\katie_000\AppData\Local\Programs\Python\Python36  \lib\tkinter\__init__.py", line 1469, in _configure
return self._getconfigure1(_flatten((self._w, cmd, '-'+cnf)))
File "C:\Users\katie_000\AppData\Local\Programs\Python\Python36\lib\tkinter\__init__.py", line 1457, in _getconfigure1
x = self.tk.splitlist(self.tk.call(*args))
_tkinter.TclError: unknown option "-You must enter a phone number"

如果有人能告诉我这意味着什么会很好,因为我找不到任何可以帮助我的信息。

非常感谢

1 个答案:

答案 0 :(得分:0)

使用label.configure("You must enter a phone number")会尝试为label分配"You must enter a phone number"属性,该属性不是Label窗口小部件具有的属性。如果您正在尝试设置窗口小部件的文本值(如上面mentalita所指出的那样),则需要将值分配给text属性,如label.configure(text="You must enter a phone number")