wxPython: Looping over all children of a sizer

Discussion in 'Python' started by Piet, May 20, 2004.

  1. Piet

    Piet Guest

    Hello,
    I need some help with the design of a "dynamic" wxDialog.
    The dialog window is divided into several sizers, the first contains a
    wxComboBox. When choosing an entry from this wxComboBox, a second
    sizer (RowColSizer) will be populated with some controls, the number
    and type of which will depend on the selected ComboBox-Entry. That
    works fine for the first selection: The wxDialog is enlarged to give
    room for the new controls. But when I make another selection, I get an
    error saying that some positions in the sizer are populated twice. It
    is obvious that the sizer has to be cleared before I put in the new
    controls. I checked the documentation and found the Remove-Method for
    sizers. Unfortunately, this method seems only to be able to remove a
    sizer completely (which is not want I want, because the sizer will be
    repopulated in the next step, and I dont want to recreate it, because
    the sizer has to keep its position in the dialog relative to the other
    sizers) or to remove the item with the specified position (which is no
    alternative as well, because the number of childs or controls in the
    sizer will vary).
    Now my question: is there a clearall-Method for sizers that removes
    all the items in the sizer or is there a function to get the number of
    childs in the sizer so that I could write something like
    for i in range(sizer.GetNumberOfChildren()):
    sizer.Remove(i)

    That would help me a lot.
    Thanks in advance
    Piet
    Piet, May 20, 2004
    #1
    1. Advertising

  2. Piet

    F. GEIGER Guest

    Since you are the one who's stuffing all the controls into the sizer, you
    are the one knowing how much of them have been stuffed into it, i.e. add
    them all to an internal list, as you add them to a sizer.

    To remove one of them you have to call wxSizer::Remove().

    HTH
    Franz GEIGER


    "Piet" <> schrieb im Newsbeitrag
    news:...
    > Hello,
    > I need some help with the design of a "dynamic" wxDialog.
    > The dialog window is divided into several sizers, the first contains a
    > wxComboBox. When choosing an entry from this wxComboBox, a second
    > sizer (RowColSizer) will be populated with some controls, the number
    > and type of which will depend on the selected ComboBox-Entry. That
    > works fine for the first selection: The wxDialog is enlarged to give
    > room for the new controls. But when I make another selection, I get an
    > error saying that some positions in the sizer are populated twice. It
    > is obvious that the sizer has to be cleared before I put in the new
    > controls. I checked the documentation and found the Remove-Method for
    > sizers. Unfortunately, this method seems only to be able to remove a
    > sizer completely (which is not want I want, because the sizer will be
    > repopulated in the next step, and I dont want to recreate it, because
    > the sizer has to keep its position in the dialog relative to the other
    > sizers) or to remove the item with the specified position (which is no
    > alternative as well, because the number of childs or controls in the
    > sizer will vary).
    > Now my question: is there a clearall-Method for sizers that removes
    > all the items in the sizer or is there a function to get the number of
    > childs in the sizer so that I could write something like
    > for i in range(sizer.GetNumberOfChildren()):
    > sizer.Remove(i)
    >
    > That would help me a lot.
    > Thanks in advance
    > Piet
    F. GEIGER, May 23, 2004
    #2
    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. Piet
    Replies:
    0
    Views:
    1,080
  2. Piet
    Replies:
    2
    Views:
    353
    Tom B.
    Sep 10, 2004
  3. John Salerno
    Replies:
    5
    Views:
    405
    Morpheus
    Jun 12, 2006
  4. Chris Brat
    Replies:
    2
    Views:
    499
    John Salerno
    Oct 30, 2006
  5. Replies:
    4
    Views:
    178
Loading...

Share This Page