2017-10-14 125 views
0

我正在尝试为学校项目创建地址簿GUI。目前我在尝试我的验证链接到GUI,但不断收到此错误信息:_tkinter.Tcl错误:未知选项

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" 

这将是巨大的,如果有人能告诉我这是什么意思,因为我无法找到任何信息帮我。

非常感谢

+0

你必须展示相关的代码,不仅是回溯。 – mentalita

+1

然而,从回溯中,我可以告诉你,你不需要像这样配置一个标签 - 如果你想设置它的文本,你需要像这样指定参数。 'label.configure(text ='你必须......')'。你也不需要'command = name()'中的括号 – mentalita

回答

0

使用label.configure("You must enter a phone number")将尝试并与"You must enter a phone number"的属性,它不是一个属性是Label部件有分配label。如果您尝试设置小部件的文本值(正如上面的mentalita指出的那样),您需要将值分配给text属性,如label.configure(text="You must enter a phone number")