I had tried using the Remove method, but found that it did delete the objects I was using. Heres the code I was using and the output it created where s.displays is a list of the objects I was trying to
switch to a new sizer.
[<C wxBoxSizer instance at _87b8ed8_wxBoxSizer_p>, <C
wxBoxSizer instance at _880fa70_wxBoxSizer_p>, None, None, None,
None]
removed
[wxPython wrapper for DELETED wxBoxSizer object! (The C++ object no
longer exists.), wxPython wrapper for DELETED wxBoxSizer object! (The
C++ object no longer exists.), None, None, None, None]
I think the reason this was failing is that the Remove function seems to delete any sizers it is removing, but doesn't delete the windows themselves.
I redid this code making each of the displays a separate object laid out
on wxPanel objects instead of using sizers and it works the way I want now.
[<C wxPanel instance at _87b8200_wxPanel_p>, <C wxPanel instance at _87ba138_wxPanel_p>, None, None, None, None]
removed
[<C wxPanel instance at _87b8200_wxPanel_p>, <C wxPanel instance at _87ba138_wxPanel_p>, None, None, None, None]
Thanks,
Andrew
···
Andrew Jones wrote:
I need to be able to detach these objects because the constructors take
a long time so I can't just make new ones. Is there some other way to
not have objects deleted when the sizer they are contained in is deleted
that I have missed? Thanks,
I think you want:
Sizer.Remove(Window)
From the docs:
Removes a child from the sizer. window is the window to be removed,
sizer is the equivalent sizer and nth is the position of the child in
the sizer, typically 0 for the first item. This method does not cause
any layout or resizing to take place and does not delete the window
itself. Call wxSizer::Layout to update the layout "on screen" after
removing a child from the sizer.
Returns TRUE if the child item was found and removed, FALSE otherwise.
def showMe(self):
for p in self.parts:
self.Add(p, ...)
def hideMe(self):
for p in self.parts:
self.Remove(p)
Thorsten
Andrew Jones wrote:
···
I had tried using the Remove method, but found that it did delete the objects I was using. Heres the code I was using and the output it created where s.displays is a list of the objects I was trying to
switch to a new sizer.
[<C wxBoxSizer instance at _87b8ed8_wxBoxSizer_p>, <C
wxBoxSizer instance at _880fa70_wxBoxSizer_p>, None, None, None,
None]
removed
[wxPython wrapper for DELETED wxBoxSizer object! (The C++ object no
longer exists.), wxPython wrapper for DELETED wxBoxSizer object! (The
C++ object no longer exists.), None, None, None, None]
I think the reason this was failing is that the Remove function seems to delete any sizers it is removing, but doesn't delete the windows themselves.
I redid this code making each of the displays a separate object laid out
on wxPanel objects instead of using sizers and it works the way I want now.
[<C wxPanel instance at _87b8200_wxPanel_p>, <C wxPanel instance at _87ba138_wxPanel_p>, None, None, None, None]
removed
[<C wxPanel instance at _87b8200_wxPanel_p>, <C wxPanel instance at _87ba138_wxPanel_p>, None, None, None, None]
Thanks,
Andrew
Andrew Jones wrote:
I need to be able to detach these objects because the constructors take
a long time so I can't just make new ones. Is there some other way to
not have objects deleted when the sizer they are contained in is deleted
that I have missed? Thanks,
I think you want:
Sizer.Remove(Window)
From the docs:
Removes a child from the sizer. window is the window to be removed,
sizer is the equivalent sizer and nth is the position of the child in
the sizer, typically 0 for the first item. This method does not cause
any layout or resizing to take place and does not delete the window
itself. Call wxSizer::Layout to update the layout "on screen" after
removing a child from the sizer.
Returns TRUE if the child item was found and removed, FALSE otherwise.
-Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
I had tried using the Remove method, but found that it did delete the objects I was using. Heres the code I was using and the output it created where s.displays is a list of the objects I was trying to
switch to a new sizer.
[<C wxBoxSizer instance at _87b8ed8_wxBoxSizer_p>, <C
wxBoxSizer instance at _880fa70_wxBoxSizer_p>, None, None, None,
None]
removed
[wxPython wrapper for DELETED wxBoxSizer object! (The C++ object no
longer exists.), wxPython wrapper for DELETED wxBoxSizer object! (The
C++ object no longer exists.), None, None, None, None]
I think the reason this was failing is that the Remove function seems to delete any sizers it is removing, but doesn't delete the windows themselves.
Yes, it was this confusion that led to Remove being depreacted in 2.5 and the addition of the Detach method.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!