Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > wxPython: Looping over all children of a sizer

Reply
Thread Tools

wxPython: Looping over all children of a sizer

 
 
Piet
Guest
Posts: n/a
 
      05-20-2004
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
 
Reply With Quote
 
 
 
 
F. GEIGER
Guest
Posts: n/a
 
      05-23-2004
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" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed) om...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Options for looping through children with different element names johkar XML 2 04-02-2009 11:06 AM
VOIP over VPN over TCP over WAP over 3G Theo Markettos UK VOIP 2 02-14-2008 03:27 PM
newb: recurse over elements children and disable all form elements SteveKlett@gmail.com Javascript 4 09-20-2006 07:42 AM
Active Directory Sizer =?Utf-8?B?d3lybWJsYWRlXzk4?= MCSE 1 06-29-2005 01:53 PM
wxPython: Need method to remove items from sizer Piet Python 0 05-21-2004 06:34 PM



Advertisments