[wxPython] adding/removing controls and windows

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] adding/removing controls and windows

Jeffrey Kunce
Hi-

I am working on my first non-trivial wxPython project. My problem is
probably simple, but I haven't found the answer in the demo code.

My app will look a lot like the wxPython demo. Click on a tree on the
left - information about the selected item is displayed on the right.
Different types of selections generate different types of displays.

Following the demo, I was able to implement this with a notebook
on the right, using DeletePage() and AddPage() to change the display.

However, I don't really need a notebook - I'd like to just change the
contents of the right side of the splitter.

My questions:

1) How can I replace stuff in one side of a splitter. The docs mention a
wxSplitterWindow:ReplaceWindow, but that doesn't seem to be implemented
in wxPython.

2) Is there a generalized solution for dynamically adding/removing
controls/windows from a window?

3) Is this a safe thing to do? (I've used systems where adding/deleting
controls can cause memory leaks, system resource problems. etc)

4) Can I keep orphan controls around for reuse? If I remove a control/window
from a window, can I save it, and later plug it into another window with its
contents intact? Can I make controls with no parent initially, and later place
them in a window?

Thanks in advance. Either direct answers or pointers to example code would
be appreciated.

  --Jeff

P.S. Is there a way to search (as opposed to browse) the mailing list archives?



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] adding/removing controls and windows

Robin Dunn
> My questions:
>
> 1) How can I replace stuff in one side of a splitter. The docs mention a
> wxSplitterWindow:ReplaceWindow, but that doesn't seem to be implemented
> in wxPython.
>

Oops!  Another one that snuck past me...  It's now there for the next
release.


> 2) Is there a generalized solution for dynamically adding/removing
> controls/windows from a window?
>

Adding is no problem.  Removing may be tricky.  You can call the Destroy
method of the window to be removed but then you can't use it anymore.  Or
you can call Reparent to remove it and put it on another window.


> 3) Is this a safe thing to do? (I've used systems where adding/deleting
> controls can cause memory leaks, system resource problems. etc)

Yes, should be.

>
> 4) Can I keep orphan controls around for reuse? If I remove a
control/window
> from a window, can I save it, and later plug it into another window with
its
> contents intact? Can I make controls with no parent initially, and later
place
> them in a window?

The only windows that can be created without a parent are top level windows,
i.e., frames and dialogs.  Perhaps if you Reparent() the control over to a
window that is not shown, and then reparent it back to the one you want
later, it might work.  But personally I think it would be easier/cleaner to
Destroy the control, save its data and then recreate it later with the saved
data.


>
> P.S. Is there a way to search (as opposed to browse) the mailing list
archives?
>

I'm working on a couple different alternatives, (egroups.com and
searchbutton.com.)  Once one or both of them have the archives indexed I'll
put a link on the wxPython page.


--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users