wxFlexGridSizer

Hi all,

  How can I remove all items from a wxFlexGridSizer object??
  I've used grid.Clear(), grid.Remove(), ... but it doesn't work. Any help??

Thanks in advance.

Why not destroy the whole sizer?

-Chris

Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

···

On Thursday, June 12, 2003, at 07:19 AM, Diego Chaparro wrote:

  How can I remove all items from a wxFlexGridSizer object??
  I've used grid.Clear(), grid.Remove(), ... but it doesn't work. Any help??

I'm trying to do that, but I can't. If I do sizer.Destroy() the application crash :-(. Maybe I'm doing something wrong.

  I have sizer2 inside sizer1:

  sizer1.Add ( sizer2, 0, wxALL, 0 )

  And then, when I want to destroy sizer2 I do:

  for elem in sizer1.GetChildren:
    elem.GetSizer().Destroy()

  What am I doing wrong?? Any help, please.

Thanks

···

Chris.Barker@noaa.gov wrote:

On Thursday, June 12, 2003, at 07:19 AM, Diego Chaparro wrote:

    How can I remove all items from a wxFlexGridSizer object??
    I've used grid.Clear(), grid.Remove(), ... but it doesn't work. Any help??

Why not destroy the whole sizer?

for elem in sizer1.GetChildren():
                                      ^^
                elem.GetSizer().Destroy()

Try adding parentheses as above and see if that helps.
GetChildren() is a method. Also, if the "elem" is already a sizer
you may only need:

                elem.Destroy()

Cheers,

···

--- Diego Chaparro <dchapar.madrid@sinvest.es> wrote:

      for elem in sizer1.GetChildren:
              elem.GetSizer().Destroy()

=====
Donnal Walter
Arkansas Children's Hospital

Diego Chaparro wrote:

    How can I remove all items from a wxFlexGridSizer object??
    I've used grid.Clear(), grid.Remove(), ... but it doesn't work. Any help??

sizer.Clear() chould do it. The window items in the sizer will still exist though, so if you want to get rid of them too then do sizer.Clear(True)

Why not destroy the whole sizer?

    I'm trying to do that, but I can't. If I do sizer.Destroy() the application crash :-(. Maybe I'm doing something wrong.

    I have sizer2 inside sizer1:

    sizer1.Add ( sizer2, 0, wxALL, 0 )

    And then, when I want to destroy sizer2 I do:

    for elem in sizer1.GetChildren():
        elem.GetSizer().Destroy()

Not sure why it is crashing, but this approach is flawed anyway. If the sizer item is not another sizer then GetSizer will return None, which of course has no Destroy method. Even so, the sizer does not own the windows it contains and so it wont destroy them too. Perhaps this will work for you?

  sizer2.Clear(True)
  sizer1.Remove(sizer2)

···

Chris.Barker@noaa.gov wrote:

On Thursday, June 12, 2003, at 07:19 AM, Diego Chaparro wrote:

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hi,

robin@alldunn.com wrote:

Diego Chaparro wrote:

Why not destroy the whole sizer?

    I'm trying to do that, but I can't. If I do sizer.Destroy() the application crash :-(. Maybe I'm doing something wrong.

    I have sizer2 inside sizer1:

    sizer1.Add ( sizer2, 0, wxALL, 0 )

    And then, when I want to destroy sizer2 I do:

    for elem in sizer1.GetChildren():
        elem.GetSizer().Destroy()

Not sure why it is crashing, but this approach is flawed anyway. If the sizer item is not another sizer then GetSizer will return None, which of course has no Destroy method. Even so, the sizer does not own the windows it contains and so it wont destroy them too. Perhaps this will work for you?

    sizer2.Clear(True)
    sizer1.Remove(sizer2)

  Thank you very much, it works perfectly :slight_smile:

Bye,