Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update values to the listbox under Combobox in ttk Python33

When I create the Combobox, it has no items in the list. Now when I click on the dropdown button a function is called (via the postcommand option), but once in my function I don't know how to set the values in the listbox of the Combobox.

Code something like this:

    #update list upon drop down
    self.cbox = Combobox(self, width = 10, postcommand = self.updtcblist)

    def updtcblist(self):
        list = self.getPortLst()
        self.cbox.getlistbox.set(list) #getlistbox doesn't work

Thanks,

Harvey

like image 219
Harvey Avatar asked Sep 19 '13 22:09

Harvey


1 Answers

Answered my own question.

I Finally found an example that helped, and got it to work with the following code:

#update list upon drop down
self.cbox = Combobox(self, width = 10, postcommand = self.updtcblist)

def updtcblist(self):
    list = self.getPortLst()
    self.cbox['values'] = list

This works as desired.

like image 148
Harvey Avatar answered Oct 13 '22 19:10

Harvey