How to clear a wxSizer without multiple Remove

Hi everyone,

Is there a way to clear the content of a wxSizer without calling Remove for each item?

Thx and regards,

Nicolas

Nicolas Fleury wrote:

Hi everyone,

Is there a way to clear the content of a wxSizer without calling Remove for each item?

Thx and regards,

Nicolas

For those interested, the only solution I found is to, as specified on the Wiki page, remove all elements and destroy them. Not destroying them was not working, and replace the sizer by a new one was not working either (I have no idea why).

Regards,

Nicolas

Nicolas Fleury wrote:

Hi everyone,

Is there a way to clear the content of a wxSizer without calling Remove for each item?

Why not just destroy the sizer and create a new one? But if you also want to destroy the windows on the sizer then you do need to traverse all the items and destroy them too.

ยทยทยท

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

Robin Dunn wrote:

Nicolas Fleury wrote:

Hi everyone,

Is there a way to clear the content of a wxSizer without calling Remove for each item?

Why not just destroy the sizer and create a new one? But if you also want to destroy the windows on the sizer then you do need to traverse all the items and destroy them too.

Well, to be honest there's few things I'm just beginning to understand and I'm still not having the big picture of wx design (and I may prove it in the next paragraphs). The first time I played with Destroy (I began playing with wx 2 weeks ago) I made my application crashed; being used to exceptions, I said to myself that I was playing with low-level stuff that carbage-collection was taking care of.

Now I'm realizing that using Destroy is part of normal wxPython programming, since sizers don't play any role in ownership. I guess a part of my early confusion was due to the coexistence of python garbage-collection of wrappers and wxWindows ownership management. For what I understand, it's possible to Destroy a C++ window, but still have a reference to a python wrapper over it. Of course that's bad programming, but I wonder if a ownership policy 100% compatible with wrappers garbage collection could be possible.

According to wx package doc, wxPython is evolving to have a more python-friendly API and the use of the "import wx" form is the first step (which I welcome very much). I currently read this mailing list as a newsgroup hosted on gmane.org, but I haven't found any news server for the wxPython-dev mailing list; does anyone know any? I would like very much to keep me informed of wxPython development.

By the way, maybe it could be a good idea to mention gmane.org on the wxpython.org web page.

Regards and thx for your wonderful work,

Nicolas