def __init__(self, parent): wx.Panel.__init__(self, parent) self.parent = parent wred = ColWin(self, wx.ID_ANY, wx.RED) wblue = ColWin(self, wx.ID_ANY, wx.BLUE) wgreen = ColWin(self, wx.ID_ANY, wx.GREEN) b = 10 hsizer1 = wx.BoxSizer(wx.HORIZONTAL) hsizer1.Add(wred, 0, wx.GROW | wx.ALL, b) hsizer1.Add(wblue, 0, wx.GROW | wx.TOP | wx.RIGHT | wx.BOTTOM, b) hsizer1.Add(wgreen, 0, wx.GROW | wx.TOP | wx.RIGHT | wx.BOTTOM, b) #force some widths of the coloured windows hsizer1.SetItemMinSize(wred, (100, -1)) hsizer1.SetItemMinSize(wblue, (100, -1)) hsizer1.SetItemMinSize(wgreen, (100, -1)) #set a height, all ColWin have the same height. hsizer1.SetMinSize((-1, 300)) #set the sizer self.SetSizerAndFit(hsizer1) #set the client size of the main frame self.parent.SetClientSize(hsizer1.GetSize()) #get the size of the main frame r = self.parent.GetSize() #set the minimal size of the main frame self.parent.SetMinSize(r) #centering self.parent.CentreOnScreen()
def __init__(self, parent): wx.Panel.__init__(self, parent) wred = ColWin(self, wx.ID_ANY, wx.RED) wwhite = ColWin(self, wx.ID_ANY, wx.WHITE) h = 40 b1 = wx.Button(self, wx.ID_ANY, '1', (-1, h)) b2 = wx.Button(self, wx.ID_ANY, '2', wx.DefaultPosition, (-1, h)) b3 = wx.Button(self, wx.ID_ANY, '3', wx.DefaultPosition, (-1, h)) b4 = wx.Button(self, wx.ID_ANY, '4', wx.DefaultPosition, (-1, h)) b5 = wx.Button(self, wx.ID_ANY, '', wx.DefaultPosition, (-1, h)) b5.Enable(False) hsizer1 = wx.BoxSizer(wx.HORIZONTAL) b = 0 f = wx.ALL hsizer1.Add(b1, 0, f, border=b) hsizer1.Add(b2, 0, f, border=b) hsizer1.Add(b3, 0, f, border=b) hsizer1.Add(b4, 0, f, border=b) hsizer1.Add(b5, 1, f | wx.EXPAND, b) b = 2 hsizer2 = wx.BoxSizer(wx.HORIZONTAL) hsizer2.Add(wred, 1, wx.EXPAND | wx.RIGHT, b) hsizer2.Add(wwhite, 1, wx.EXPAND | wx.LEFT, b) b = 5 vsizer1 = wx.BoxSizer(wx.VERTICAL) vsizer1.Add(hsizer1, 0, wx.EXPAND, b) vsizer1.Add(hsizer2, 1, wx.ALL | wx.EXPAND, b) self.SetSizer(vsizer1)
def __init__(self, parent): wx.Panel.__init__(self, parent) wred = ColWin(self, wx.ID_ANY, wx.NamedColour('green')) wgreen = ColWin(self, wx.ID_ANY, wx.NamedColour('red')) wblue = ColWin(self, wx.ID_ANY, wx.NamedColour('blue')) b = 10 sizer1 = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, 'Staticbox'), wx.VERTICAL) sizer1.Add(wred, 1, wx.EXPAND | wx.ALL, b) sizer2 = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, 'Staticbox'), wx.VERTICAL) sizer2.Add(wgreen, 1, wx.EXPAND | wx.ALL, b) sizer4 = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, 'Staticbox'), wx.VERTICAL) sizer4.Add(wblue, 1, wx.EXPAND | wx.ALL, b) #tricky: the 2nd and 3rd staticbox sizer are shifted one pixel to the #left, try with b2 = 0 b1, b2 = 0, -1 sizer3 = wx.BoxSizer(wx.HORIZONTAL) sizer3.Add(sizer1, 1, wx.EXPAND, b1) sizer3.Add(sizer2, 1, wx.EXPAND | wx.LEFT, b2) sizer3.Add(sizer4, 1, wx.EXPAND | wx.LEFT, b2) self.SetSizer(sizer3)
def __init__(self, parent): wx.Panel.__init__(self, parent) self.wred = ColWin(self, wx.ID_ANY, wx.RED) self.wblue = ColWin(self, wx.ID_ANY, wx.BLUE) b1 = wx.Button(self, wx.ID_ANY, 'Show / Hide wred', wx.DefaultPosition, wx.DefaultSize) b2 = wx.Button(self, wx.ID_ANY, 'Show / Hide wblue', wx.DefaultPosition, wx.DefaultSize) b1.Bind(wx.EVT_BUTTON, self.OnClick1) b2.Bind(wx.EVT_BUTTON, self.OnClick2) hsizer1 = wx.BoxSizer(wx.HORIZONTAL) b = 8 hsizer1.Add(b1, 0, wx.RIGHT, b) hsizer1.Add(b2, 0, border=b) b = 4 hsizer2 = wx.BoxSizer(wx.HORIZONTAL) hsizer2.Add(self.wred, 1, wx.EXPAND | wx.RIGHT, b) hsizer2.Add(self.wblue, 1, wx.EXPAND | wx.LEFT, b) b = 4 vsizer1 = wx.BoxSizer(wx.VERTICAL) vsizer1.Add(hsizer1, 0, wx.ALL, b) vsizer1.Add(hsizer2, 1, wx.ALL | wx.EXPAND, b) self.SetSizer(vsizer1)
def __init__(self, parent): wx.Panel.__init__(self, parent) wred = ColWin(self, wx.ID_ANY, wx.RED) wblue = ColWin(self, wx.ID_ANY, wx.BLUE) wwhite = ColWin(self, wx.ID_ANY, wx.WHITE) wcyan = ColWin(self, wx.ID_ANY, wx.CYAN) hgap, vgap = 0, 0 nrows, ncols = 2, 2 fgs = wx.FlexGridSizer(nrows, ncols, hgap, vgap) b = 5 fgs.AddMany([ (wred, 1, wx.EXPAND | wx.ALL, b), (wblue, 1, wx.EXPAND | wx.ALL, b), (wwhite, 1, wx.EXPAND | wx.ALL, b), (wcyan, 1, wx.EXPAND | wx.ALL, b), ]) # or #~ fgs.Add(wred, 1, wx.EXPAND | wx.ALL, b) #~ fgs.Add(wblue, 1, wx.EXPAND | wx.ALL, b) #~ fgs.Add(wwhite, 1, wx.EXPAND | wx.ALL, b) #~ fgs.Add(wcyan, 1, wx.EXPAND | wx.ALL, b) #set all rows and cols sizable, try to comment / uncomment fgs.AddGrowableRow(0) fgs.AddGrowableRow(1) fgs.AddGrowableCol(0) fgs.AddGrowableCol(1) self.SetSizer(fgs)
def __init__(self, parent): wx.Panel.__init__(self, parent) self.parent = parent ItemSize = (200, 100) wblue2 = ColWin(self, wx.ID_ANY, wx.BLUE) wblue2.SetSize(ItemSize) hgap, vgap = 0, 0 nrows, ncols = 3, 3 fgs = wx.FlexGridSizer(nrows, ncols, hgap, vgap) b = 0 fgs.AddMany([ (-1, -1), (-1, -1), (-1, -1), (-1, -1), (wblue2, 0, wx.ALL, b), (-1, -1), (-1, -1), (-1, -1), (-1, -1), ]) fgs.AddGrowableRow(0) fgs.AddGrowableRow(2) fgs.AddGrowableCol(0) fgs.AddGrowableCol(2) self.SetSizer(fgs) self.parent.SetSize((500, 400)) self.parent.CentreOnScreen()
def __init__(self, parent): wx.Panel.__init__(self, parent) h = 40 wwhite = ColWin(self, wx.ID_ANY, wx.WHITE) wblue = ColWin(self, wx.ID_ANY, wx.BLUE) wgreen = ColWin(self, wx.ID_ANY, wx.GREEN) wred = ColWin(self, wx.ID_ANY, wx.RED) hgap, vgap = 0, 0 nrows, ncols = 3, 3 fgs = wx.FlexGridSizer(nrows, ncols, hgap, vgap) b = 5 fgs.AddMany([ ((-1, -1), 1, wx.EXPAND | wx.ALL, b), (wwhite, 1, wx.EXPAND | wx.ALL, b), ((-1, -1), 1, wx.EXPAND | wx.ALL, b), (wblue, 1, wx.EXPAND | wx.ALL, b), ((-1, -1), 1, wx.EXPAND | wx.ALL, b), (wgreen, 1, wx.EXPAND | wx.ALL, b), ((-1, -1), 1, wx.EXPAND | wx.ALL, b), (wred, 1, wx.EXPAND | wx.ALL, b), ((-1, -1), 1, wx.EXPAND | wx.ALL, b), ]) fgs.AddGrowableRow(1) fgs.AddGrowableCol(0) fgs.AddGrowableCol(1) fgs.AddGrowableCol(2) self.SetSizer(fgs)
def __init__(self, parent): wx.Panel.__init__(self, parent) wred = ColWin(self, wx.ID_ANY, wx.RED) wblue = ColWin(self, wx.ID_ANY, wx.BLUE) wgreen = ColWin(self, wx.ID_ANY, wx.GREEN) wwhite = ColWin(self, wx.ID_ANY, wx.WHITE) wyellow = ColWin(self, wx.ID_ANY, wx.NamedColour('yellow')) b = 10 vsbsizer1 = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, 'blue'), wx.VERTICAL) vsbsizer1.Add(wblue, 1, wx.EXPAND | wx.ALL, b) vsbsizer2 = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, 'white'), wx.VERTICAL) vsbsizer2.Add(wwhite, 1, wx.EXPAND | wx.ALL, b) b = 5 vsizer1 = wx.BoxSizer(wx.VERTICAL) vsizer1.Add(wred, 1, wx.EXPAND | wx.ALL, b) vsizer1.Add(vsbsizer1, 1, wx.EXPAND | wx.ALL, b) vsizer1.Add(wgreen, 1, wx.EXPAND | wx.ALL, b) vsizer1.Add(vsbsizer2, 1, wx.EXPAND | wx.ALL, b) vsizer1.Add(wyellow, 1, wx.EXPAND | wx.ALL, b) self.SetSizer(vsizer1)
def __init__(self, parent): wx.Panel.__init__(self, parent) wred = ColWin(self, wx.ID_ANY, wx.RED) wwhite = ColWin(self, wx.ID_ANY, wx.WHITE) b1 = wx.Button(self, wx.ID_ANY, '1') b2 = wx.Button(self, wx.ID_ANY, '2') b3 = wx.Button(self, wx.ID_ANY, '3') b4 = wx.Button(self, wx.ID_ANY, '4') b5 = wx.Button(self, wx.ID_ANY, '5') vsizer1 = wx.BoxSizer(wx.VERTICAL) b = 3 vsizer1.Add(wred, 1, wx.EXPAND | wx.BOTTOM, b) vsizer1.Add(wwhite, 0, wx.EXPAND, b) vsizer2 = wx.BoxSizer(wx.VERTICAL) b = 5 vsizer2.Add(b1, 0, wx.BOTTOM, b) vsizer2.Add(b2, 0, wx.BOTTOM, b) vsizer2.Add(b3, 0, wx.BOTTOM, b) vsizer2.Add(b4, 0, wx.BOTTOM, b) vsizer2.Add(b5, 0, wx.BOTTOM, b) hsizer1 = wx.BoxSizer(wx.HORIZONTAL) b = 10 hsizer1.Add(vsizer1, 1, wx.EXPAND | wx.LEFT | wx.TOP | wx.BOTTOM, b) hsizer1.Add(vsizer2, 0, wx.EXPAND | wx.ALL, b) # hsizer1.SetSizeHints(self) self.SetSizer(hsizer1)
def __init__(self, parent): wx.Panel.__init__(self, parent) wwhite = ColWin(self, wx.ID_ANY, wx.WHITE) wblue = ColWin(self, wx.ID_ANY, wx.BLUE) wgreen = ColWin(self, wx.ID_ANY, wx.GREEN) wred = ColWin(self, wx.ID_ANY, wx.RED) wgrey = ColWin(self, wx.ID_ANY, '#a0a0a0') wpink = ColWin(self, wx.ID_ANY, wx.NamedColour('pink')) wyellow = ColWin(self, wx.ID_ANY, wx.NamedColour('yellow')) wcyan = ColWin(self, wx.ID_ANY, wx.NamedColour('cyan')) worange = ColWin(self, wx.ID_ANY, wx.NamedColour('orange')) hstaline1 = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, (-1, 2), wx.LI_HORIZONTAL) hstaline2 = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, (-1, 2), wx.LI_HORIZONTAL) vstaline1 = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, (2, -1), wx.LI_VERTICAL) vstaline2 = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, (2, -1), wx.LI_VERTICAL) vgap, hgap = 4, 4 gbs = wx.GridBagSizer(vgap, hgap) b = 0 f = wx.EXPAND | wx.ALL b2 = 8 f2 = wx.EXPAND | wx.TOP | wx.BOTTOM b3 = 8 f3 = wx.EXPAND | wx.LEFT | wx.RIGHT gbs.Add(wwhite, (0, 0), (1, 1), f, b) gbs.Add(vstaline1, (0, 1), (5, 1), f3, b3) gbs.Add(wblue, (0, 2), (1, 1), f, b) gbs.Add(vstaline2, (0, 3), (5, 1), f3, b3) gbs.Add(wgreen, (0, 4), (1, 1), f, b) gbs.Add(hstaline1, (1, 0), (1, 5), f2, b2) gbs.Add(wred, (2, 0), (1, 1), f, b) gbs.Add(wgrey, (2, 2), (1, 1), f, b) gbs.Add(wpink, (2, 4), (1, 1), f, b) gbs.Add(hstaline2, (3, 0), (1, 5), f, b2) gbs.Add(wyellow, (4, 0), (1, 1), f, b) gbs.Add(wcyan, (4, 2), (1, 1), f, b) gbs.Add(worange, (4, 4), (1, 1), f, b) gbs.AddGrowableRow(0) gbs.AddGrowableRow(2) gbs.AddGrowableRow(4) gbs.AddGrowableCol(0) gbs.AddGrowableCol(2) gbs.AddGrowableCol(4) self.SetSizer(gbs)
def __init__(self, parent): wx.Panel.__init__(self, parent) wred = ColWin(self, wx.ID_ANY, wx.RED) wblue = ColWin(self, wx.ID_ANY, wx.BLUE) b = 5 vsizer1 = wx.BoxSizer(wx.VERTICAL) vsizer1.Add(wred, 1, wx.EXPAND | wx.ALL, b) vsizer1.Add(wblue, 1, wx.EXPAND | wx.ALL, b) self.SetSizer(vsizer1)
def __init__(self, parent): wx.Panel.__init__(self, parent) wwhite = ColWin(self, wx.ID_ANY, wx.WHITE) wblue = ColWin(self, wx.ID_ANY, wx.BLUE) wgreen = ColWin(self, wx.ID_ANY, wx.GREEN) wred = ColWin(self, wx.ID_ANY, wx.RED) hstaline1 = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, (-1, 2), wx.LI_HORIZONTAL) hstaline2 = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, (-1, 2), wx.LI_HORIZONTAL) hstaline3 = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, (-1, 2), wx.LI_HORIZONTAL) vstaline1 = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, (2, -1), wx.LI_VERTICAL) vstaline2 = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, (2, -1), wx.LI_VERTICAL) vstaline3 = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, (2, -1), wx.LI_VERTICAL) vgap, hgap = 4, 4 gbs = wx.GridBagSizer(vgap, hgap) b = 8 f = wx.EXPAND | wx.ALL b2 = 8 f2 = wx.EXPAND | wx.TOP | wx.BOTTOM b3 = 8 f3 = wx.EXPAND | wx.LEFT | wx.RIGHT gbs.Add(hstaline1, (0, 0), (1, 5), f, b) gbs.Add(vstaline1, (1, 0), (3, 1), f, b) gbs.Add(wwhite, (1, 1), (1, 1), f, b) gbs.Add(vstaline2, (1, 2), (3, 1), f, b) gbs.Add(wblue, (1, 3), (1, 1), f, b) gbs.Add(vstaline3, (1, 4), (3, 1), f, b) gbs.Add(hstaline2, (2, 1), (1, 3), f, b) gbs.Add(wgreen, (3, 1), (1, 1), f, b) gbs.Add(wred, (3, 3), (1, 1), f, b) gbs.Add(hstaline3, (4, 0), (1, 5), f, b) gbs.AddGrowableRow(1) gbs.AddGrowableRow(3) gbs.AddGrowableCol(1) gbs.AddGrowableCol(3) self.SetSizer(gbs)
def __init__(self, parent): wx.Panel.__init__(self, parent) wred = ColWin(self, wx.ID_ANY, wx.RED) wblue = ColWin(self, wx.ID_ANY, wx.BLUE) wgreen = ColWin(self, wx.ID_ANY, wx.GREEN) b = 5 hsizer1 = wx.BoxSizer(wx.HORIZONTAL) hsizer1.Add(wred, 1, wx.EXPAND | wx.ALL, b) hsizer1.Add(wblue, 2, wx.EXPAND | wx.ALL, b) hsizer1.Add(wgreen, 3, wx.EXPAND | wx.ALL, b) self.SetSizer(hsizer1)
def __init__(self, parent): wx.Panel.__init__(self, parent) wred = ColWin(self, wx.ID_ANY, wx.RED) wblue = ColWin(self, wx.ID_ANY, wx.BLUE) b = 5 vsizer1 = wx.BoxSizer(wx.VERTICAL) vsizer1.Add(wred, 1, wx.EXPAND | wx.ALL, b) #add a fixed width of 50 pixels between the two items. vsizer1.Add((-1, 50), 0, wx.ALL, b) vsizer1.Add(wblue, 1, wx.EXPAND | wx.ALL, b) self.SetSizer(vsizer1)
def __init__(self, parent): wx.Panel.__init__(self, parent) self.parent = parent self.wred = ColWin(self, wx.ID_ANY, wx.RED) self.wgreen = ColWin(self, wx.ID_ANY, wx.GREEN) b1 = wx.Button(self, wx.ID_ANY, 'detach / insert wred', wx.DefaultPosition, wx.DefaultSize) b2 = wx.Button(self, wx.ID_ANY, 'detach / insert wgreen', wx.DefaultPosition, wx.DefaultSize) b3 = wx.Button(self, wx.ID_ANY, 'swap wrec / wgreen', wx.DefaultPosition, wx.DefaultSize) b4 = wx.Button(self, wx.ID_ANY, '4', wx.DefaultPosition, wx.DefaultSize) b1.Bind(wx.EVT_BUTTON, self.OnClick1) b2.Bind(wx.EVT_BUTTON, self.OnClick2) b3.Bind(wx.EVT_BUTTON, self.OnClick3) b4.Bind(wx.EVT_BUTTON, self.OnClick4) #toolbar hsizer1 = wx.BoxSizer(wx.HORIZONTAL) b = 8 hsizer1.Add(b1, 0, wx.RIGHT, b) hsizer1.Add(b2, 0, wx.RIGHT, b) hsizer1.Add(b3, 0, wx.RIGHT, b) hsizer1.Add(b4, 0, border=b) #A horizontal sizer holding the green and red windows. Both windows #are visible at start. #note the same flag border for both windows (swapping) self.bb = 5 self.hsizer2 = wx.BoxSizer(wx.HORIZONTAL) self.hsizer2.Add(self.wred, 1, wx.EXPAND | wx.ALL, self.bb) self.hsizer2.Add(self.wgreen, 1, wx.EXPAND | wx.ALL, self.bb) b = 5 self.vsizer1 = wx.BoxSizer(wx.VERTICAL) self.vsizer1.Add(hsizer1, 0, wx.ALL, b) self.vsizer1.Add(self.hsizer2, 1, wx.ALL | wx.EXPAND, b) self.SetSizer(self.vsizer1) self.parent.SetClientSize((500, 300)) self.parent.CentreOnScreen() #the two windows are shown assert self.wred.IsShown() == True assert self.wgreen.IsShown() == True
def __init__(self, parent): wx.Panel.__init__(self, parent) wred = ColWin(self, wx.ID_ANY, wx.RED) wblue = ColWin(self, wx.ID_ANY, wx.BLUE) wgreen = ColWin(self, wx.ID_ANY, wx.GREEN) b = 10 #inside the staticbox vsbsizer1 = wx.StaticBoxSizer( wx.StaticBox(self, wx.ID_ANY, 'StaticboxSizer with a caption'), wx.VERTICAL) vsbsizer1.Add(wred, 1, wx.EXPAND | wx.ALL, b) vsbsizer1.Add(wblue, 1, wx.EXPAND | wx.ALL, b) vsbsizer1.Add(wgreen, 1, wx.EXPAND | wx.ALL, b) self.SetSizer(vsbsizer1)
def __init__(self, parent): wx.Panel.__init__(self, parent) wgreen = ColWin(self, wx.ID_ANY, wx.NamedColour('green')) b1 = wx.Button(self, wx.ID_ANY, 'button1') b2 = wx.Button(self, wx.ID_ANY, 'button2') b3 = wx.Button(self, wx.ID_ANY, 'button3') b = 0 hsizer1 = wx.BoxSizer(wx.HORIZONTAL) hsizer1.Add(b1, 0, wx.ALL, b) hsizer1.AddStretchSpacer() hsizer1.Add(b2, 0, wx.ALL, b) hsizer1.AddStretchSpacer() hsizer1.Add(b3, 0, wx.ALL, b) ## tip: this does not work # b = 100 # hsizer1 = wx.BoxSizer(wx.HORIZONTAL) # hsizer1.Add(b1, 0, wx.ALIGN_LEFT, b) # hsizer1.Add(b2, 0, wx.ALIGN_CENTER, b) # hsizer1.Add(b3, 0, wx.ALIGN_RIGHT, b) b = 5 vsizer2 = wx.BoxSizer(wx.VERTICAL) vsizer2.Add(wgreen, 1, wx.EXPAND | wx.ALL, b) vsizer2.Add(hsizer1, 0, wx.EXPAND | wx.ALL, b) # vsizer2.SetSizeHints(self) self.SetSizer(vsizer2)
def __init__(self, parent): wx.Panel.__init__(self, parent) wgreen = ColWin(self, wx.ID_ANY, wx.NamedColour('green')) b1 = wx.Button(self, wx.ID_ANY, 'button1') b2 = wx.Button(self, wx.ID_ANY, 'button2') b3 = wx.Button(self, wx.ID_ANY, 'button3') b4 = wx.Button(self, wx.ID_ANY, 'button4') b = 0 hsizer1a = wx.BoxSizer(wx.HORIZONTAL) hsizer1a.Add(b2, 0, wx.ALL, b) hsizer1a.Add(b3, 0, wx.ALL, b) b = 0 hsizer1 = wx.BoxSizer(wx.HORIZONTAL) hsizer1.Add(b1, 0, wx.ALL, b) hsizer1.AddStretchSpacer() hsizer1.Add(hsizer1a, 0, wx.ALL, b) hsizer1.AddStretchSpacer() hsizer1.Add(b4, 0, wx.ALL, b) b = 0 hsizer1b = wx.BoxSizer(wx.HORIZONTAL) hsizer1b.AddStretchSpacer() hsizer1b.Add(wgreen, 1, wx.EXPAND | wx.ALL, b) hsizer1b.AddStretchSpacer() b = 5 vsizer2 = wx.BoxSizer(wx.VERTICAL) vsizer2.Add(hsizer1, 0, wx.EXPAND | wx.ALL, b) vsizer2.Add(hsizer1b, 1, wx.EXPAND | wx.ALL, b) self.SetSizer(vsizer2)
def __init__(self, parent): wx.Panel.__init__(self, parent) self.parent = parent ItemSize = (200, 100) wblue2 = ColWin(self, wx.ID_ANY, wx.BLUE) wblue2.SetSize(ItemSize) hsizer1 = wx.BoxSizer(wx.HORIZONTAL) b = 0 hsizer1.AddStretchSpacer() hsizer1.Add(wblue2, 0, wx.ALIGN_CENTER | wx.ALL, b) hsizer1.AddStretchSpacer() self.SetSizer(hsizer1) self.parent.SetClientSize((400, 400)) self.parent.CenterOnScreen()
def __init__(self, parent): wx.Panel.__init__(self, parent) wred = ColWin(self, wx.ID_ANY, wx.RED) wblue = ColWin(self, wx.ID_ANY, wx.BLUE) wgreen = ColWin(self, wx.ID_ANY, wx.GREEN) b = 0 h = 20 hsizer1 = wx.BoxSizer(wx.VERTICAL) hsizer1.Add(wred, 1, wx.EXPAND | wx.ALL, b) # a fixed width of 20 pixels between the two items. hsizer1.Add((-1, h)) hsizer1.Add(wblue, 1, wx.EXPAND | wx.ALL, b) hsizer1.Add((-1, h)) hsizer1.Add(wgreen, 1, wx.EXPAND | wx.ALL, b) self.SetSizer(hsizer1)
def __init__(self, parent): wx.Panel.__init__(self, parent) self.parent = parent wwhite = ColWin(self, wx.ID_ANY, wx.WHITE) wblue = ColWin(self, wx.ID_ANY, wx.BLUE) wgreen = ColWin(self, wx.ID_ANY, wx.GREEN) wred = ColWin(self, wx.ID_ANY, wx.RED) #~ wgrey = ColWin(self, wx.ID_ANY, '#aaaaaa') #~ wpink = ColWin(self, wx.ID_ANY, wx.NamedColour('pink')) #~ wyellow = ColWin(self, wx.ID_ANY, wx.NamedColour('yellow')) #~ wcyan = ColWin(self, wx.ID_ANY, wx.NamedColour('cyan')) #~ worange = ColWin(self, wx.ID_ANY, wx.NamedColour('orange')) #~ wbrown = ColWin(self, wx.ID_ANY, wx.NamedColour('brown')) hgap, vgap = 10, 10 gbs = wx.GridBagSizer(vgap, hgap) b = 0 f = wx.EXPAND | wx.ALL gbs.Add(wwhite, (0, 0), (1, 1), f, b) gbs.Add(wblue, (0, 1), (1, 1), f, b) gbs.AddSpacer((30, -1), (0, 2)) gbs.AddSpacer((-1, 25), (1, 0)) gbs.Add(wgreen, (2, 0), (1, 1), f, b) gbs.Add(wred, (2, 1), (1, 1), f, b) gbs.AddSpacer((-1, 50), (3, 0)) #the line below also works #~ gbs.Add((-1, 50), (3, 0)) gbs.AddGrowableRow(0) gbs.AddGrowableRow(2) gbs.AddGrowableCol(0) gbs.AddGrowableCol(1) self.SetSizerAndFit(gbs) #~ self.SetSizer(gbs) #set a size self.parent.SetClientSize((300, 300)) self.parent.CentreOnScreen()
def __init__(self, parent): wx.Panel.__init__(self, parent) self.parent = parent self.wblue = ColWin(self, wx.ID_ANY, wx.BLUE) self.wblue.SetName('wblue') b1 = wx.Button(self, wx.ID_ANY, 'Items infos', name='b1') b1.Bind(wx.EVT_BUTTON, self.OnClick1) #toolbar self.hsizer1 = wx.BoxSizer(wx.HORIZONTAL) b = 20 self.hsizer1.Add(b1, 0, wx.ALL, b) self.hsizer1.Add(self.wblue, 1, wx.EXPAND | wx.ALL, b) self.hsizer1.SetItemMinSize(self.wblue, (100, 75)) self.SetSizerAndFit(self.hsizer1) self.parent.SetClientSize(self.hsizer1.GetSize())
def __init__(self, parent): wx.Panel.__init__(self, parent) # A green ColWin as sizer item. wgreen = ColWin(self, wx.ID_ANY, wx.GREEN) # Setup the sizer b = 20 vsizer1 = wx.BoxSizer(orient=wx.VERTICAL) vsizer1.Add(item=wgreen, proportion=1, flag=wx.EXPAND | wx.ALL, border=b) self.SetSizer(vsizer1)
class MyPanel1(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) self.wred = ColWin(self, wx.ID_ANY, wx.RED) self.wblue = ColWin(self, wx.ID_ANY, wx.BLUE) b1 = wx.Button(self, wx.ID_ANY, 'Show / Hide wred', wx.DefaultPosition, wx.DefaultSize) b2 = wx.Button(self, wx.ID_ANY, 'Show / Hide wblue', wx.DefaultPosition, wx.DefaultSize) b1.Bind(wx.EVT_BUTTON, self.OnClick1) b2.Bind(wx.EVT_BUTTON, self.OnClick2) hsizer1 = wx.BoxSizer(wx.HORIZONTAL) b = 8 hsizer1.Add(b1, 0, wx.RIGHT, b) hsizer1.Add(b2, 0, border=b) b = 4 hsizer2 = wx.BoxSizer(wx.HORIZONTAL) hsizer2.Add(self.wred, 1, wx.EXPAND | wx.RIGHT, b) hsizer2.Add(self.wblue, 1, wx.EXPAND | wx.LEFT, b) b = 4 vsizer1 = wx.BoxSizer(wx.VERTICAL) vsizer1.Add(hsizer1, 0, wx.ALL, b) vsizer1.Add(hsizer2, 1, wx.ALL | wx.EXPAND, b) self.SetSizer(vsizer1) def OnClick1(self, event): if self.wred.IsShown(): self.wred.Show(False) self.Layout() elif not self.wred.IsShown(): self.wred.Show(True) self.Layout() else: pass def OnClick2(self, event): if self.wblue.IsShown(): self.wblue.Show(False) self.Layout() elif not self.wblue.IsShown(): self.wblue.Show(True) self.Layout() else: pass
def __init__(self, parent): wx.Panel.__init__(self, parent) self.parent = parent ItemSize = (200, 100) wblue2 = ColWin(self, wx.ID_ANY, wx.BLUE) #A item (ColWin) with a fixed size wblue2.SetSize(ItemSize) vsizer1 = wx.BoxSizer(wx.VERTICAL) b = 0 vsizer1.AddStretchSpacer() #~ vsizer1.Add((-1, -1), 1) #old #centered vsizer1.Add(wblue2, 0, wx.ALIGN_CENTER | wx.ALL, b) vsizer1.AddStretchSpacer() #~ vsizer1.Add((-1, -1), 1) #old self.SetSizer(vsizer1) self.parent.SetClientSize((400, 400)) self.parent.CenterOnScreen()
def __init__(self, parent): wx.Panel.__init__(self, parent) self.parent = parent #do not do this #~ self.parent.SetClientSize((800, 400)) wgreen = ColWin(self, wx.ID_ANY, wx.GREEN) s = 'abc' s = '' si = (150, -1) lab1 = wx.StaticText(self, wx.ID_ANY, s, size=si) lab2 = wx.StaticText(self, wx.ID_ANY, s, size=si) lab3 = wx.StaticText(self, wx.ID_ANY, s, size=si) lab4 = wx.StaticText(self, wx.ID_ANY, s, size=si) lab5 = wx.StaticText(self, wx.ID_ANY, s, size=si) lab6 = wx.StaticText(self, wx.ID_ANY, s, size=si) all = [lab1, lab2, lab3, lab4, lab5, lab6] for e in all: e.SetBackgroundColour((255, 255, 200)) hgap, vgap = 5, 5 nrows, ncols = 3, 2 fgs = wx.FlexGridSizer(nrows, ncols, hgap, vgap) f = wx.ALL #| wx.EXPAND b = 0 fgs.AddMany([ (lab1, 0, f, b), (lab2, 0, f, b), (lab3, 0, f, b), (lab4, 0, f, b), (lab5, 0, f, b), (lab6, 0, f, b), ]) #~ fgs.AddGrowableCol(0) #~ fgs.AddGrowableCol(1) b = 5 vsizer1 = wx.BoxSizer(wx.VERTICAL) #~ vsizer1.Add((-1, 100)) vsizer1.Add(wgreen, 0, wx.ALL | wx.ALIGN_CENTER, b) vsizer1.Add(fgs, 0, wx.ALL | wx.ALIGN_CENTER, b) vsizer1.SetItemMinSize(wgreen, (380, 130)) self.SetSizer(vsizer1) self.parent.SetClientSize(vsizer1.GetMinSize()) self.parent.CentreOnScreen() sty = wx.SYSTEM_MENU | wx.CAPTION | wx.MINIMIZE_BOX | wx.CLOSE_BOX #~ self.parent.SetStyle(sty) self.parent.SetWindowStyle(sty)
def __init__(self, parent): wx.Panel.__init__(self, parent) self.parent = parent ItemSize = (100, 100) wblue = ColWin(self, wx.ID_ANY, wx.BLUE) wblue.SetSize(ItemSize) wred = ColWin(self, wx.ID_ANY, wx.RED) wred.SetSize(ItemSize) hsizer1 = wx.BoxSizer(wx.HORIZONTAL) b = 0 hsizer1.AddStretchSpacer() hsizer1.Add(wblue, 0, wx.ALL, b) hsizer1.AddStretchSpacer() hsizer1.Add(wred, 0, wx.ALL, b) hsizer1.AddStretchSpacer() vsizer1 = wx.BoxSizer(wx.VERTICAL) b = 0 vsizer1.AddStretchSpacer() vsizer1.Add(hsizer1, 0, wx.EXPAND | wx.ALL, b) vsizer1.AddStretchSpacer() self.SetSizer(vsizer1) self.parent.SetClientSize((400, 400)) self.parent.CenterOnScreen()
def __init__(self, parent): wx.Panel.__init__(self, parent) self.parent = parent #~ self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False)) wblue = ColWin(self, wx.ID_ANY, wx.BLUE) wred = ColWin(self, wx.ID_ANY, wx.RED) b1 = wx.Button(self, wx.ID_ANY, 'button1') b2 = wx.Button(self, wx.ID_ANY, 'button2') sty = wx.CB_DROPDOWN sty = wx.CB_READONLY maxsi = (100, -1) ch1 = ['alpha', 'beta', 'gamma'] cb1 = wx.ComboBox(self, wx.ID_ANY, ch1[0], choices=ch1, style=sty) #~ cb1.SetMaxSize(maxsi) ch2 = ['aaa', 'bb bb', 'ccc ccc ccc'] cb2 = wx.ComboBox(self, wx.ID_ANY, ch2[0], choices=ch2, style=sty) #~ cb2.SetMaxSize(maxsi) b = 5 hsizer1 = wx.BoxSizer(wx.HORIZONTAL) hsizer1.Add(b1, 0, wx.ALL, b) hsizer1.Add(wblue, 1, wx.EXPAND | wx.ALL, b) hsizer1.Add(cb1, 1, wx.EXPAND | wx.ALL, b) hsizer2 = wx.BoxSizer(wx.HORIZONTAL) hsizer2.Add(cb2, 1, wx.EXPAND | wx.ALL, b) hsizer2.Add(b2, 0, wx.ALL, b) hsizer2.Add(wred, 1, wx.EXPAND | wx.ALL, b) vsizer1 = wx.BoxSizer(wx.VERTICAL) vsizer1.Add(hsizer1, 0, wx.EXPAND | wx.ALL, b) vsizer1.Add(hsizer2, 0, wx.EXPAND | wx.ALL, b) self.SetSizerAndFit(vsizer1) self.parent.SetClientSize(vsizer1.GetSize())
def __init__(self, parent): wx.Panel.__init__(self, parent) self.wred = ColWin(self, wx.ID_ANY, wx.RED) self.wwhite = ColWin(self, wx.ID_ANY, wx.WHITE) self.wgreen = ColWin(self, wx.ID_ANY, wx.GREEN) b1 = wx.Button(self, wx.ID_ANY, 'Show / Hide wred', wx.DefaultPosition, wx.DefaultSize) b2 = wx.Button(self, wx.ID_ANY, 'Show / Hide wwhite', wx.DefaultPosition, wx.DefaultSize) b3 = wx.Button(self, wx.ID_ANY, 'Show / Hide wgreen', wx.DefaultPosition, wx.DefaultSize) b1.Bind(wx.EVT_BUTTON, self.OnClick1) b2.Bind(wx.EVT_BUTTON, self.OnClick2) b3.Bind(wx.EVT_BUTTON, self.OnClick3) vsizer1 = wx.BoxSizer(wx.VERTICAL) b = 8 vsizer1.Add(b1, 0, wx.BOTTOM, b) vsizer1.Add(b2, 0, wx.BOTTOM, b) vsizer1.Add(b3, 0, border=b) b = 4 hsizer2 = wx.BoxSizer(wx.HORIZONTAL) hsizer2.Add(self.wred, 1, wx.EXPAND | wx.ALL, b) hsizer2.Add(self.wwhite, 2, wx.EXPAND | wx.ALL, b) hsizer2.Add(self.wgreen, 3, wx.EXPAND | wx.ALL, b) hsizer2.Add(vsizer1, 0, wx.ALL, b) self.SetSizer(hsizer2)
def __init__(self, parent): wx.Panel.__init__(self, parent) self.parent = parent #~ self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False)) wblue = ColWin(self, wx.ID_ANY, wx.BLUE) wred = ColWin(self, wx.ID_ANY, wx.RED) b1 = wx.Button(self, wx.ID_ANY, 'button1') b2 = wx.Button(self, wx.ID_ANY, 'button2') sty = wx.LB_SINGLE ch1 = ['alpha', 'beta', 'gamma'] lb1 = wx.ListBox(self, wx.ID_ANY, size=(-1, 50), choices=ch1, style=sty) ch2 = ['aaa', 'bb bb', 'ccc ccc ccc', 'ddd', 'eee', 'fff', 'ggg', 'hhh', 'iii', 'jjj'] lb2 = wx.ListBox(self, wx.ID_ANY, choices=ch2, style=sty) b = 5 hsizer1 = wx.BoxSizer(wx.HORIZONTAL) hsizer1.Add(b1, 0, wx.ALL, b) hsizer1.Add(wblue, 1, wx.EXPAND | wx.ALL, b) hsizer1.Add(lb1, 0, wx.EXPAND | wx.ALL, b) hsizer2 = wx.BoxSizer(wx.HORIZONTAL) hsizer2.Add(lb2, 1, wx.EXPAND | wx.ALL, b) hsizer2.Add(b2, 0, wx.ALL, b) hsizer2.Add(wred, 1, wx.EXPAND | wx.ALL, b) vsizer1 = wx.BoxSizer(wx.VERTICAL) # Listbox1 is not expanded and keep its size. #~ vsizer1.Add(hsizer1, 0, wx.EXPAND | wx.ALL, b) # Listbox1 is expanded. vsizer1.Add(hsizer1, 1, wx.EXPAND | wx.ALL, b) vsizer1.Add(hsizer2, 1, wx.EXPAND | wx.ALL, b) self.SetSizer(vsizer1)