【发布时间】:2016-01-24 16:54:06
【问题描述】:
from tkinter import *
#Create the window
root = Tk()
#Modify root window
root.title("Simple GUI")
root.geometry("200x50")
app = frame(root)
label = Label(app, text = "This is a label")
label.grid()
#kick of the event loop
root.mainloop()
我正在关注 YouTube 的教程来了解 Python tkinter GUI。 但是当我运行上面的代码时,它会出现错误。
Traceback (most recent call last):
File "C:/Users/Nathan/Desktop/Python/Python GUI/Simple GUI.py", line 14, in <module>
app = frame(root)
NameError: name 'frame' is not defined
我知道这与frame 有关,我尝试了Frame,但它不起作用。
能不能帮我搞定,谢谢!
我目前使用的是 Python 3.5,教程在 2.7 中
【问题讨论】:
-
当您说您尝试过
Frame但没有成功时,错误是什么?Frame是合适的解决方案。
标签: python user-interface tkinter python-3.5