Application structure - basic knowledge needed

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. :slight_smile:

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?

Sorry for stupid questions...

Algirdas

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. :slight_smile:

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!

There are certainly more elegant ways to do it, but your approach is not fundamentally wrong.

Any way to describe it in 2 or 3 words? I can use Google :slight_smile: But for the keywords that I can invent I find nothing usefull.

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?

Yes. But as my user will be not so friendly with computers I decided to stay with menu - user will need to pass all menu entrys to get system functional.

From the other hanf if You say that it is not so bad idea to create panels at

the beginning it should be much easier and simplier to use notebooks...

Than You for Your ansewer

Algirdas

···

----- Original Message ----- From: "Robin Dunn" <robin@alldunn.com>
To: <wxPython-users@lists.wxwidgets.org>
Sent: Wednesday, February 20, 2008 2:40 AM
Subject: Re: [wxPython-users] Application structure - basic knowledge needed