O.K. I've done an experiment here to see how I'll do this.
class MyFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title)
sizer = wx.BoxSizer()
self.SetSizer(sizer)
self.panel1 = SomePanel(self)
self.panel2 = AnotherPanel(self)
sizer.Add(self. panel1, 1, flag = wx.EXPAND)
sizer.Add(self. panel2, 1, flag = wx.EXPAND)
self. panel2.Hide()
sizer.Fit(self)
self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPress)
self.toggle = False
def OnKeyPress(self, event):
self.toggle = not self.toggle
if self.toggle:
self. panel1.Hide()
self. panel2.Show()
else:
self. panel2.Hide()
self. panel1.Show()
event.Skip()
Right now the sub-panels don't have any active controls, so the frame itself is collecting the events. The first panel only has a button on it. The second panel has a custom control in it which has a set minimum size which is larger than the button on the first panel, so the second panel would be bigger than the first panel. I want my frame to be the size of the second (larger) panel, though I only show the first panel on startup. Both panels have a sizer to which I've added their controls to.
There are two problems with this. First, the frame is the size of the first panel on startup instead of the size of the second panel. Secondly, when I switch panels the new panel is only properly redrawn when I manually resize the frame.
···
On 27-Jan-08, at 1:04 PM, C M wrote:
Ok, that makes it much clearer for me to picture. What you are describing should not be too tough at all.
Basically what you could do is create all your panels and manage the size of the controls within them using sizers, like BoxSizer or whatever. If you are new to sizers, there is some tutorials out there on that, or you could try them or fool around with them in the demo, or ask questions, etc. But sizers will allow you have have "their contents stretched somehow" very nicely.
You then would start off (on init) by hiding all but the title screen. You would then put the appropriate Hide() and Show() commands linked to event handlers on particular controls, meaning if you pressed a button it would show the appropriate panel and hide the others. As I understand it, Hide() and Show() work well with sizers in that the sizer takes into account only panels which are shown--that's a big help in this.
There are probably more clever ways of handling multiple panels in this way (that is what Notebook tries to simplify, but I understand that is not part of the game standard look), but if you just start with two panels and use sizers and then try switching between them, it should become more intuitive to you.