How to delete elements from Tix Combo Box?

dudeja.rajat at dudeja.rajat at
Sat Aug 30 15:51:40 CEST 2008

On Sat, Aug 30, 2008 at 2:32 PM, Fredrik Lundh <fredrik at> wrote:
> dudeja.rajat at wrote:
>> I'm using a Tix combo box (I call it combo2), the contents of which
>> are loaded depeding on the selection in another Tix combo box(I call
>> it combo1)
>> I have used the commands:
>> self.cbAnalysisLibVersion.insert(END, results)
>> to insert elements to the combo box.
>> I'm looking for some similar option to delete elements from the combo
>> box. I mean, as soon as I change selection in
>> combo1 the previous elements in the combo2 should get cleared up( or
>> deleted) and | shall be able to the above insert command to add new
>> elements to the combo2 ( depending upon selection in combo1)
>> Please suggest how can I clear up the ( delete the entries) in combo2.
> no time to test this, but iirc, the combobox content is held in an ordinary
> listbox widget, so you should be able to use the subwidget method to fetch
> that widget, and then use ordinary listbox methods to change the content.
>  Something like this:
>    lb = w.subwidget("listbox")
>    lb.delete(0, END) # delete all items
> </F>
> --

Fredrik, Thanks so much. That worked.

Following this, I can now see that my combo2 has no previous elements
and contains only the elements relevant to selection in combo1.

Now, as soon as I select something in combo 2 and go back to change
selection in combo1 the combo2 must get its history cleared up (i.e
the previous selection in combo2's entry subwidget)

I used the command before I delete the entires :
self.combo2.config(history = False)

But this does not seem to be working;

Here is my code snippet:
Inside the callback function of combo1:

for libName, libResults in self.__libVerDict.items():
                if libName == selectedLibName:
                    #Get the list of labelled results
                    resultsVer = self.__libVerDict[libName]
                    self.combo2.config(state = NORMAL)
                    self.combo2.config(history = False)
                    #Delete the previous entries from the listbox
                    #subwidget of combo box
                    subLB = self.combo2.subwidget("listbox")
                    subLB.delete(0, END)
                    #Add the results to the combo box
                    for results in resultsVer:
                        self.combo2.insert(END, results)


More information about the Python-list mailing list