Re: How to delete elements from Tix Combo Box?

Discussion in 'Python' started by dudeja.rajat@gmail.com, Aug 30, 2008.

  1. Guest

    On Sat, Aug 30, 2008 at 2:32 PM, Fredrik Lundh <> wrote:
    > 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>
    >
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >


    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)


    --
    Regards,
    Rajat
     
    , Aug 30, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    298
  2. Replies:
    0
    Views:
    393
  3. Replies:
    0
    Views:
    277
  4. dthmtlgod

    Fill Combo Box based on another Combo Box

    dthmtlgod, Nov 16, 2005, in forum: ASP General
    Replies:
    1
    Views:
    624
    Bob Barrows [MVP]
    Nov 16, 2005
  5. SM
    Replies:
    2
    Views:
    403
Loading...

Share This Page