我使用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:\Python27\lib\lib-tk\Tkinter.py", line 1470, in __call__
return self.func(*args)
File "C:\Users\Administrator\PycharmProjects\SSPFAT\SSPANIMATE\XMLGEN.py", line 318, in cancelButtonClick
self.inputset = [self.pipent.get(),self.hosent.get(),self.tent.get(),self.lent.get(),self.pent.get()]
File "C:\Python27\lib\lib-tk\Tix.py", line 341, in __getattr__
raise AttributeError, name
AttributeError: get
请您告诉我如何从组合框中获取条目?
答案 0 :(得分:1)
使用self.tent['selection']
代替self.tent.get()