AttributeError:'_tkinter.tkapp'对象没有属性'mainloop'

时间:2020-07-04 13:03:32

标签: python-3.x tkinter

from tkinter import *

root = Tk()

#creating a label widget
myLabel = Label(root, text="Module selection")
#displaying it on the screen
myLabel.pack()


root.mainLoop()

所以我只是看这个非常简单的tkinter教程视频https://www.youtube.com/watch?v=YXPyB4XeYLA

,并且我已经收到此错误。我完全按照他的步骤。该代码是否过期?

1 个答案:

答案 0 :(得分:1)

您刚刚将骆驼皮用于mainloop()

from tkinter import *

root = Tk()

#creating a label widget
myLabel = Label(root, text="Module selection")
#displaying it on the screen
myLabel.pack()


root.mainloop()