. , . , . "" .Hide() , .ShowYourself. - Wizard-Like,
I am trying to put a sizer on a panel. As you can see from picture http://tinypic.com/r/14nh651/5 , I canโt get sizer to occupy the whole panel. The image is not displayed during preview, so here it is at http://tinypic.com/r/14nh651/5 .
import wx
import sys
class MyApp(
wx.App # This makes a subclass of the wx.App class
):
def OnInit(self):
self.frame = MyFrame(None)
self.frame.Show()
self.SetTopWindow(self.frame)
return True
def OnExit(self):
print 'Dying ...'
class MyFrame(
wx.Frame # This makes a subclass of the wx.Frame class
):
"""Frame class that displays an image."""
def __init__(self,
image,
parent=None, # "None" as a parameter means this is a top-level window
id=-1, # "-1" means automatically generate a new ID
title='Generic Title', # What words appear in the title bar?
pos=wx.DefaultPosition, # Where is the upper left-hand corner?
style=wx.CAPTION | wx.STAY_ON_TOP # Style with only a caption
):
"""Create a wx.Frame instance and display image."""
size = (500, 500)
wx.Frame.__init__(self, parent, id, 'Program Title', pos, size, style)
sizer_h = wx.BoxSizer(wx.HORIZONTAL)
self.panelX = TestLayout3(self)
sizer_h.Add(self.panelX)
self.SetSizer(sizer_h)
self.panelX.ShowYourself()
def ShutDown(self):
self.Destroy()
class TestLayout3(wx.Panel):
def __init__(self, parent, id=-1):
size = (600, 600)
wx.Panel.__init__(self, parent, id, size)
a, b, c, d, e, f, g = [wx.Button(self, -1, 4*c) for c in 'ABCDEFG']
a.SetMaxSize((200,100))
hs0 = wx.BoxSizer(wx.HORIZONTAL)
hs0.Add(a, 1, wx.ALIGN_LEFT)
hs0.Add((0,0), 1)
hs0.Add(b, 0, wx.ALIGN_RIGHT)
hs2 = wx.BoxSizer(wx.HORIZONTAL)
hs2.Add(d, 0, wx.ALIGN_LEFT)
hs2.Add((10,10), 0)
hs2.Add(e, 0)
hs2.Add((10,10), 0)
hs2.Add(f, 0)
hs2.Add((10, 10), 1)
hs2.Add(g, 0, wx.ALIGN_RIGHT)
vs = wx.BoxSizer(wx.VERTICAL)
vs.Add(hs0, flag=wx.EXPAND)
vs.Add(c, 1, flag=wx.EXPAND)
vs.Add(hs2, flag=wx.EXPAND)
self.SetSizer(vs)
self.Raise()
self.SetPosition((0,0))
self.Fit()
self.Hide()
def ShowYourself(self):
self.Raise()
self.SetPosition((0,0))
self.Fit()
self.Show()
def OnBack(self, event):
self.Hide()
self.GetParent().panel1.ShowYourself()
def OnNext(self, event):
self.Hide()
self.GetParent().panel1.ShowYourself()
![
def OnCancelAndExit(self, event):
self.GetParent().ShutDown()
def main():
app = MyApp(redirect = False)
app.MainLoop()
if __name__ == '__main__':
main()][3]