Nested sizer removal confusion

Hi All,

I've tried to work my head around removing a boxsizer that's nested in
another sizer, but for the life of me, I'm just not seeing clearly.

What I want to achieve is to first create a "list" of controls in
horizontal box sizers nested in a parent vertical box sizer (not a
problem). At some arbitrary time in the future, the user clicks a
button in one of those horizontal box sizers, and that "row" gets
removed.

I can't get this to work. I've searched through the archives, but most
of what I turned up was from the Python 2.2 days. I've attached some
sample code ... Warning, it's pretty verbose at the moment, dumping lots
of stuff to stderr so that I can see what is where. To see my problem,
click "Button 2" in the example. You'll notice that button 3 disappears
but things have tanked: the parent sizer still seems to think it has 3
nested sizers -- until I click button 2 again, in which case the debug
shows me that it has only buttons 1 & 3, yet displays 1 & 2. Oy, much
confusion.

I've tried it both using Python 2.4.3 (Enthought) with wx 2.6.1.0 as
well as Python 2.5.1 (stock) with wx 2.8.3.0 both on Win32.

Any suggestions?

Thanks,
Anthony.

delete_sizer_test.py (2.78 KB)

ยทยทยท

--
Anthony Floyd, PhD
Convergent Manufacturing Technologies Inc.
6190 Agronomy Rd, Suite 403
Vancouver BC V6T 1Z3
CANADA

Email: Anthony.Floyd@convergent.ca | Tel: 604-822-9682
WWW: http://www.convergent.ca | Fax: 604-822-9659

CMT is hiring: See http://www.convergent.ca for details

Tuesday, April 24, 2007, 9:07:56 PM, Anthony M. Floyd wrote:

Hi All,

I've tried to work my head around removing a boxsizer that's nested in
another sizer, but for the life of me, I'm just not seeing clearly.

What I want to achieve is to first create a "list" of controls in
horizontal box sizers nested in a parent vertical box sizer (not a
problem). At some arbitrary time in the future, the user clicks a
button in one of those horizontal box sizers, and that "row" gets
removed.

I can't get this to work. I've searched through the archives, but most
of what I turned up was from the Python 2.2 days. I've attached some
sample code ... Warning, it's pretty verbose at the moment, dumping lots
of stuff to stderr so that I can see what is where. To see my problem,
click "Button 2" in the example. You'll notice that button 3 disappears
but things have tanked: the parent sizer still seems to think it has 3
nested sizers -- until I click button 2 again, in which case the debug
shows me that it has only buttons 1 & 3, yet displays 1 & 2. Oy, much
confusion.

I've tried it both using Python 2.4.3 (Enthought) with wx 2.6.1.0 as
well as Python 2.5.1 (stock) with wx 2.8.3.0 both on Win32.

Any suggestions?

Some time ago I was stuck on the same issue you describe and I wrote
GlobSizer, which was intended to be a GridBagSizer on steroids. The
methods you might find useful here are InsertRow, InsertCol, DeleteRow
and DeleteCol. GlobSizer also handles issues like, for example,
deleting a row that has a widget that spans for several rows including
the one that you're about to delete.

If you don't mind dealing with a 'new' sizer (and reading some
Brazilian Portuguese strings), please see the attached files.
"globsizer.py" contains the GlobSizer class, and "srchdialog.py" is
the smoke test to be run (a search dialog). To test the sizer's
Insert/Delete row methods you'll just have to click the "Adicionar"
(Add) and "Remover" (Remove) buttons. Plus, "srchdialog.py" also
handles the tab order issues that may arise when controls are added or
deleted.

-- tacao

No bits were harmed during the making of this e-mail.

srchdialog.py (7.86 KB)

globsizer.py (15.7 KB)