[wxPython-users] Application structure - basic knowledge needed
Robin Dunn
robin at alldunn.com
Tue Feb 19 16:40:51 PST 2008
Algirdas Brazas wrote:
> Dear friends,
>
> I am porting my web based application (wich is actually db interface for
> some databases) written in php to wxpython. I took me only several
> rewritings to understand, that I miss something in a global scope.
> There is an application wich will have a main frame and 10-20 different
> panels wich will be shown on it. For each panel I need to show a little
> bit different menu and completely different toolbar in the main frame.
> What should be my approach for this? At the moment I use this before
> creating any panel:
> if hasattr(self, "win"):
> if hasattr(self.win, "OnClose"):
> self.win.OnClose()
> self.win.Destroy()
> del self.win
> While any things I need to clean after any panel I can put in the
> OnClose method of it. One of those things is:
> self.parent.SetToolBar(None)
> self.toolbar.Destroy()
> del self.toolbar
> Then cleaning up inserted menu entries...
> And I don't think it's right. :)
There are certainly more elegant ways to do it, but your approach is not
fundamentally wrong.
> From the other hand - what should be good way to show different
> panels? Should I
> create them once and then simply switch, or is it better to create them
> when needed?
Either way works, but if you create all the panels at the beginning and
then just Show/Hide as needed, then the transition between panels will
be quicker and will look somewhat better.
BTW, have you considered using wx.Notebook or one of the other book widgets?
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list