Hi,
Java has a layout manager called CardLayout that allows
you to have several components that occupy the same window,
but where only one component at the time is being shown.
How can I accomplish the same thing in wxPython?
I have tried to write the following subclass to wxPanel and it
works good as long as the "Cards" doesn't contain a scroller.
It probably has something to do with the sizing algorithm that
doesn't take the size of the cards into accordance at the
top-level, but before I delve in to the mysterious world of
autolayout, could someone please tell me if this is the right way
to solve the problem?
Kind regards
//Jan Persson
--- cut here ----------------------------------------------
class CardPanel(wxPanel):
def __init__(self, parent, id, style=0):
wxPanel.__init__(self, parent, id, style=style)
self.panels = {}
self.boxsizer = wxBoxSizer(wxVERTICAL)
self.SetSizer(self.boxsizer)
self.SetAutoLayout(true)
self.active_panel = None
def add_card(self, panel, id):
self.panels[id] = panel
def show_card(self,id):
if self.active_panel:
self.active_panel.Show(0)
self.boxsizer.Remove(self.active_panel)
panel = self.panels[id]
self.boxsizer.AddWindow(panel, 1, wxGROW)
panel.Show(1)
self.Layout()
self.active_panel = panel
def get_active_panel(self):
return self.active_panel
def get_active_panel_id(self):
for k in self.panels.keys():
if self.panels[k] == self.active_panel:
return k
return None
def get_panels(self):
return self.panels
···
=====
Jan Persson (Consultant) Bitmine AB
Email: jan@bitmine.se Regementsgatan 2
Mobile: +46 706 321721 211 42 Malm�
Office: +46 40 6905860 SWEDEN
----------------------------------------------------
Free Dmitry Sklyarov! - http://freesklyarov.org/
__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com