我使用Tkinter包生成了GUI。它有一些我用命令创建的条目
self.tent = Entry(self.side_options_frame)
self.tent.pack(padx=5, pady=6)
然后,我决定添加ComboBox,我不想使用ttk包,所以我用命令创建了ComboBox
from Tix import Tk, Control, ComboBox
self.tent = ComboBox(self.side_options_frame, label=' ',editable = True)
for temp in ('sim_trainer', 'sim_trainer:49916'):
self.tent.insert(END,temp)
self.tent.pack(padx=5, pady=6)
问题是,以前我可以使用"self.tent.get()"获取条目,但现在我得到了一个错误:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:Python27liblib-tkTkinter.py", line 1470, in __call__
return self.func(*args)
File "C:UsersAdministratorPycharmProjectsSSPFATSSPANIMATEXMLGEN.py", line 318, in cancelButtonClick
self.inputset = [self.pipent.get(),self.hosent.get(),self.tent.get(),self.lent.get(),self.pent.get()]
File "C:Python27liblib-tkTix.py", line 341, in __getattr__
raise AttributeError, name
AttributeError: get
你能告诉我如何从我的combobox中获得条目吗?
使用self.tent['selection']
而不是self.tent.get()