|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import tkinter
top=tkinter.Tk
label1=tkinter.Label(top,text='在窗体显示输出内容!')
label1.pack()
top.mainloop()
/Users/snow/PycharmProjects/pythoncrashcourse/venv/bin/python /Users/snow/PycharmProjects/pythonfromzerotoone/partone.py
Traceback (most recent call last):
File "/Users/snow/PycharmProjects/pythonfromzerotoone/partone.py", line 17, in <module>
label1=tkinter.Label(top,text='在窗体显示输出内容!')
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tkinter/__init__.py", line 2766, in __init__
Widget.__init__(self, master, 'label', cnf, kw)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tkinter/__init__.py", line 2292, in __init__
BaseWidget._setup(self, master, cnf)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tkinter/__init__.py", line 2262, in _setup
self.tk = master.tk
AttributeError: type object 'Tk' has no attribute 'tk'
Process finished with exit code 1
怎么才能不报错呢?
import tkinter
top=tkinter.Tk()
label1=tkinter.Label(top,text='在窗体显示输出内容!')
label1.pack()
top.mainloop()
这个要加括号才行哦~
|
|