pythoncomboboxtkintertix

Get value from a ComboBox using tix, Tkinter


I generated my GUI using Tkinter package. It has some entries that I created with these commands

self.tent = Entry(self.side_options_frame)
self.tent.pack(padx=5, pady=6)

Then, I decided to add ComboBox, and I do not want to use ttk package, so I created ComboBox with these commands

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)

The problem is that, before I could get my entry using "self.tent.get()", but now I get an error of:

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

Could you please let me know how can I get the entry from my combobox?


Solution

  • Use self.tent['selection'] instead of self.tent.get()