我正在尝试创建一个基本的 Gmail 客户端,但我似乎在动态创建 Tkinter 按钮时遇到了问题。在我的课堂Main_Window
上,我有一个方法叫做mainFun
. 在这个方法中是这段代码,它试图创建 11 个编号为 1-11 的按钮。
for i in range(1,11):
self.newmessage = Button(self, text = "%d" % i)
Main_Window.entryFrame.append(self.newmessage)
烦人的是,我在运行代码时遇到错误。
Python 2.7.3 (default, Aug 1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type "copyright", "credits" or "license()" for more information.
==== No Subprocess ====
>>>
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1413, in __call__
return self.func(*args)
File "/media/PI_USB/Email Send/Email Send GUI V2.py", line 111, in remember_Authen
self.authen_credits()
File "/media/PI_USB/Email Send/Email Send GUI V2.py", line 101, in authen_credits
app = Main_Window()
File "/media/PI_USB/Email Send/Email Send GUI V2.py", line 225, in __init__
self.mainFun()
File "/media/PI_USB/Email Send/Email Send GUI V2.py", line 281, in mainFun
Main_Window.entryFrame.append(self.newmessage)
AttributeError: class Main_Window has no attribute 'entryFrame'
如果需要,这是我其余代码的 pastebin 链接:
谢谢你!