flexGridsizer clarification

(wx2.8.10, winXP)

I have a sizer situation like so:

------- MainboxSizer (VERTICAL)
    --------MainFlexGridSizer
                  A B
                  C D
                  E [F1 F2]
                  G H

The letters are widgets, the brackets represent another flexGridSizer
within MainFlexGridSizer.

Question: If I Destroy() widgets E, F1, and F2, should that entire
"row" now functionally disappear from MainFlexGridSizer? So that it
would look like?:

------- MainboxSizer (VERTICAL)
    --------MainFlexGridSizer
                  A B
                  C D
                  G H

Because it seems like what I am getting is

------- MainboxSizer (VERTICAL)
    --------MainFlexGridSizer
                  A B
                  C D
                          G
                  H

And that's not what I want. Do I have to explicitly get rid of the
smaller flexGridSizer? I tried Destroy() on it, but I get an
unhandled exception in Boa.

Thanks

Hi Che,

(wx2.8.10, winXP)

I have a sizer situation like so:

------- MainboxSizer (VERTICAL)
     --------MainFlexGridSizer
                   A B
                   C D
                   E [F1 F2]
                   G H

The letters are widgets, the brackets represent another flexGridSizer
within MainFlexGridSizer.

Question: If I Destroy() widgets E, F1, and F2, should that entire
"row" now functionally disappear from MainFlexGridSizer? So that it
would look like?:

------- MainboxSizer (VERTICAL)
     --------MainFlexGridSizer
                   A B
                   C D
                   G H

Because it seems like what I am getting is

------- MainboxSizer (VERTICAL)
     --------MainFlexGridSizer
                   A B
                   C D
                           G
                   H

And that's not what I want. Do I have to explicitly get rid of the
smaller flexGridSizer? I tried Destroy() on it, but I get an
unhandled exception in Boa.

What was the exception?

You need to at least remove the small sizer from the main one, but I think that del/destroy should work to.

Another option might be to hide the widgets.

In both cases you would need to call Layout on the main sizer.

See you
Werner

···

On 02/08/2013 05:29, C M wrote:

What was the exception?

Hi Werner,

It caused a Windows error, so there was no error msg printed.

It turned out if I Detach()ed the items first, then Destroy()ed the
widgets, it worked. I guess they were being "waited on" by the sizer,
and then by destroying the C++ part, I got an error. I thought there
was a one command way to do this, but maybe not.

Just a side note: Detach() is a little odd when you have detach two
sizer items that are one after the other. I had to call, for example:

sizer.Detach(8)
sizer.Detach(8)

to detach the sizer item's in the 8th and 9th position, since, after
the first call, the 9th was now in the 8th position. It makes sense,
but perhaps a gotcha if one is not paying attention.

Thanks.

Hi Che,

What was the exception?

Hi Werner,

It caused a Windows error, so there was no error msg printed.

I have seen this before when something is incorrectly done to/with a sizer - would be nice to get an exception.

It turned out if I Detach()ed the items first, then Destroy()ed the
widgets, it worked. I guess they were being "waited on" by the sizer,
and then by destroying the C++ part, I got an error. I thought there
was a one command way to do this, but maybe not.

Are you sure you did it in the correct order?

del F1
del F2
del E
del small sizer
mainSizer.Layout()

Werner

···

On 02/08/2013 08:37, C M wrote:

C M wrote:

(wx2.8.10, winXP)

I have a sizer situation like so:

------- MainboxSizer (VERTICAL)
     --------MainFlexGridSizer
                   A B
                   C D
                   E [F1 F2]
                   G H

The letters are widgets, the brackets represent another flexGridSizer
within MainFlexGridSizer.

Question: If I Destroy() widgets E, F1, and F2, should that entire
"row" now functionally disappear from MainFlexGridSizer? So that it
would look like?:

------- MainboxSizer (VERTICAL)
     --------MainFlexGridSizer
                   A B
                   C D
                   G H

Because it seems like what I am getting is

------- MainboxSizer (VERTICAL)
     --------MainFlexGridSizer
                   A B
                   C D
                           G
                   H

And that's not what I want. Do I have to explicitly get rid of the
smaller flexGridSizer?

Yes. The sizer is still there taking up that slot in the MainFlexGridSizer so everything that comes after it will be positioned accordingly.

I tried Destroy() on it, but I get an
unhandled exception in Boa.

Widgets will remove themselves from the sizer they belong to when the widget is destroyed, but sizers do not so you'll have to Remove() it yourself. The Remove will also destroy the sizer for you. Follow that by a Layout of the main sizer and that should take care of it.

···

--
Robin Dunn
Software Craftsman