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