X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8fa876ca9ec87e90605808bfcab4d4226965dbad..f5766910b6731eb03e82371416e9778203396ce7:/wxPython/demo/Sizers.py?ds=sidebyside diff --git a/wxPython/demo/Sizers.py b/wxPython/demo/Sizers.py index 252a635776..97db7945f7 100644 --- a/wxPython/demo/Sizers.py +++ b/wxPython/demo/Sizers.py @@ -1,8 +1,3 @@ -# 11/13/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# o Issues exist that will probably need to be addressed in the 2.5 build. -# # 11/26/2003 - Jeff Grimmett (grimmtooth@softhome.net) # # o Had to do a bit of rework for the demo; there was no panel attached @@ -18,14 +13,58 @@ import wx +#---------------------------------------------------------------------- + +class SampleWindow(wx.PyWindow): + """ + A simple window that is used as sizer items in the tests below to + show how the various sizers work. + """ + def __init__(self, parent, text, pos=wx.DefaultPosition, size=wx.DefaultSize): + wx.PyWindow.__init__(self, parent, -1, + #style=wx.RAISED_BORDER + #style=wx.SUNKEN_BORDER + style=wx.SIMPLE_BORDER + ) + self.text = text + if size != wx.DefaultSize: + self.bestsize = size + else: + self.bestsize = (80,25) + self.SetSize(self.GetBestSize()) + + self.Bind(wx.EVT_PAINT, self.OnPaint) + self.Bind(wx.EVT_SIZE, self.OnSize) + self.Bind(wx.EVT_LEFT_UP, self.OnCloseParent) + + + def OnPaint(self, evt): + sz = self.GetSize() + dc = wx.PaintDC(self) + w,h = dc.GetTextExtent(self.text) + dc.Clear() + dc.DrawText(self.text, (sz.width-w)/2, (sz.height-h)/2) + + def OnSize(self, evt): + self.Refresh() + + def OnCloseParent(self, evt): + p = wx.GetTopLevelParent(self) + if p: + p.Close() + + def DoGetBestSize(self): + return self.bestsize + + #---------------------------------------------------------------------- def makeSimpleBox1(win): box = wx.BoxSizer(wx.HORIZONTAL) - box.Add(wx.Button(win, -1, "one"), 0, wx.EXPAND) - box.Add(wx.Button(win, -1, "two"), 0, wx.EXPAND) - box.Add(wx.Button(win, -1, "three"), 0, wx.EXPAND) - box.Add(wx.Button(win, -1, "four"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "one"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "two"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "three"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "four"), 0, wx.EXPAND) return box @@ -33,10 +72,10 @@ def makeSimpleBox1(win): def makeSimpleBox2(win): box = wx.BoxSizer(wx.VERTICAL) - box.Add(wx.Button(win, -1, "one"), 0, wx.EXPAND) - box.Add(wx.Button(win, -1, "two"), 0, wx.EXPAND) - box.Add(wx.Button(win, -1, "three"), 0, wx.EXPAND) - box.Add(wx.Button(win, -1, "four"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "one"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "two"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "three"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "four"), 0, wx.EXPAND) return box @@ -44,11 +83,11 @@ def makeSimpleBox2(win): def makeSimpleBox3(win): box = wx.BoxSizer(wx.HORIZONTAL) - box.Add(wx.Button(win, -1, "one"), 0, wx.EXPAND) - box.Add(wx.Button(win, -1, "two"), 0, wx.EXPAND) - box.Add(wx.Button(win, -1, "three"), 0, wx.EXPAND) - box.Add(wx.Button(win, -1, "four"), 0, wx.EXPAND) - box.Add(wx.Button(win, -1, "five"), 1, wx.EXPAND) + box.Add(SampleWindow(win, "one"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "two"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "three"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "four"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "five"), 1, wx.EXPAND) return box @@ -56,11 +95,11 @@ def makeSimpleBox3(win): def makeSimpleBox4(win): box = wx.BoxSizer(wx.HORIZONTAL) - box.Add(wx.Button(win, -1, "one"), 0, wx.EXPAND) - box.Add(wx.Button(win, -1, "two"), 0, wx.EXPAND) - box.Add(wx.Button(win, -1, "three"), 1, wx.EXPAND) - box.Add(wx.Button(win, -1, "four"), 1, wx.EXPAND) - box.Add(wx.Button(win, -1, "five"), 1, wx.EXPAND) + box.Add(SampleWindow(win, "one"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "two"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "three"), 1, wx.EXPAND) + box.Add(SampleWindow(win, "four"), 1, wx.EXPAND) + box.Add(SampleWindow(win, "five"), 1, wx.EXPAND) return box @@ -68,11 +107,11 @@ def makeSimpleBox4(win): def makeSimpleBox5(win): box = wx.BoxSizer(wx.HORIZONTAL) - box.Add(wx.Button(win, -1, "one"), 0, wx.EXPAND) - box.Add(wx.Button(win, -1, "two"), 0, wx.EXPAND) - box.Add(wx.Button(win, -1, "three"), 3, wx.EXPAND) - box.Add(wx.Button(win, -1, "four"), 1, wx.EXPAND) - box.Add(wx.Button(win, -1, "five"), 1, wx.EXPAND) + box.Add(SampleWindow(win, "one"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "two"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "three"), 3, wx.EXPAND) + box.Add(SampleWindow(win, "four"), 1, wx.EXPAND) + box.Add(SampleWindow(win, "five"), 1, wx.EXPAND) return box @@ -80,37 +119,37 @@ def makeSimpleBox5(win): def makeSimpleBox6(win): box = wx.BoxSizer(wx.HORIZONTAL) - box.Add(wx.Button(win, -1, "one"), 1, wx.ALIGN_TOP) - box.Add(wx.Button(win, -1, "two"), 1, wx.EXPAND) - box.Add(wx.Button(win, -1, "three"), 1, wx.ALIGN_CENTER) - box.Add(wx.Button(win, -1, "four"), 1, wx.EXPAND) - box.Add(wx.Button(win, -1, "five"), 1, wx.ALIGN_BOTTOM) + box.Add(SampleWindow(win, "one"), 1, wx.ALIGN_TOP) + box.Add(SampleWindow(win, "two"), 1, wx.EXPAND) + box.Add(SampleWindow(win, "three"), 1, wx.ALIGN_CENTER) + box.Add(SampleWindow(win, "four"), 1, wx.EXPAND) + box.Add(SampleWindow(win, "five"), 1, wx.ALIGN_BOTTOM) return box #---------------------------------------------------------------------- def makeSimpleBox7(win): - box = wxBoxSizer(wxHORIZONTAL) - box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND) - box.Add(wxButton(win, 1010, "two"), 0, wxEXPAND) - box.Add(wxButton(win, 1010, "three"), 0, wxEXPAND) - box.Add((60, 20), 0, wxEXPAND) - box.Add(wxButton(win, 1010, "five"), 1, wxEXPAND) + box = wx.BoxSizer(wx.HORIZONTAL) + box.Add(SampleWindow(win, "one"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "two"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "three"), 0, wx.EXPAND) + box.Add((60, 20), 0, wx.EXPAND) + box.Add(SampleWindow(win, "five"), 1, wx.EXPAND) return box #---------------------------------------------------------------------- def makeSimpleBox8(win): - box = wxBoxSizer(wxVERTICAL) - box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND) + box = wx.BoxSizer(wx.VERTICAL) + box.Add(SampleWindow(win, "one"), 0, wx.EXPAND) box.Add((0,0), 1) - box.Add(wxButton(win, 1010, "two"), 0, wxALIGN_CENTER) + box.Add(SampleWindow(win, "two"), 0, wx.ALIGN_CENTER) box.Add((0,0), 1) - box.Add(wxButton(win, 1010, "three"), 0, wxEXPAND) - box.Add(wxButton(win, 1010, "four"), 0, wxEXPAND) -# box.Add(wxButton(win, 1010, "five"), 1, wxEXPAND) + box.Add(SampleWindow(win, "three"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "four"), 0, wx.EXPAND) +# box.Add(SampleWindow(win, "five"), 1, wx.EXPAND) return box @@ -119,7 +158,7 @@ def makeSimpleBox8(win): def makeSimpleBorder1(win): bdr = wx.BoxSizer(wx.HORIZONTAL) - btn = wx.Button(win, -1, "border") + btn = SampleWindow(win, "border") btn.SetSize((80, 80)) bdr.Add(btn, 1, wx.EXPAND|wx.ALL, 15) @@ -129,7 +168,7 @@ def makeSimpleBorder1(win): def makeSimpleBorder2(win): bdr = wx.BoxSizer(wx.HORIZONTAL) - btn = wx.Button(win, -1, "border") + btn = SampleWindow(win, "border") btn.SetSize((80, 80)) bdr.Add(btn, 1, wx.EXPAND | wx.EAST | wx.WEST, 15) @@ -139,7 +178,7 @@ def makeSimpleBorder2(win): def makeSimpleBorder3(win): bdr = wx.BoxSizer(wx.HORIZONTAL) - btn = wx.Button(win, -1, "border") + btn = SampleWindow(win, "border") btn.SetSize((80, 80)) bdr.Add(btn, 1, wx.EXPAND | wx.NORTH | wx.WEST, 15) @@ -151,26 +190,26 @@ def makeSimpleBorder3(win): def makeBoxInBox(win): box = wx.BoxSizer(wx.VERTICAL) - box.Add(wx.Button(win, -1, "one"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "one"), 0, wx.EXPAND) box2 = wx.BoxSizer(wx.HORIZONTAL) - box2.Add(wx.Button(win, -1, "two"), 0, wx.EXPAND) - btn3 = wx.Button(win, -1, "three") + box2.Add(SampleWindow(win, "two"), 0, wx.EXPAND) + btn3 = SampleWindow(win, "three") box2.Add(btn3, 0, wx.EXPAND) - box2.Add(wx.Button(win, -1, "four"), 0, wx.EXPAND) - box2.Add(wx.Button(win, -1, "five"), 0, wx.EXPAND) + box2.Add(SampleWindow(win, "four"), 0, wx.EXPAND) + box2.Add(SampleWindow(win, "five"), 0, wx.EXPAND) box3 = wx.BoxSizer(wx.VERTICAL) - box3.AddMany([ (wx.Button(win, -1, "six"), 0, wx.EXPAND), - (wx.Button(win, -1, "seven"), 2, wx.EXPAND), - (wx.Button(win, -1, "eight"), 1, wx.EXPAND), - (wx.Button(win, -1, "nine"), 1, wx.EXPAND), + box3.AddMany([ (SampleWindow(win, "six"), 0, wx.EXPAND), + (SampleWindow(win, "seven"), 2, wx.EXPAND), + (SampleWindow(win, "eight"), 1, wx.EXPAND), + (SampleWindow(win, "nine"), 1, wx.EXPAND), ]) box2.Add(box3, 1, wx.EXPAND) box.Add(box2, 1, wx.EXPAND) - box.Add(wx.Button(win, -1, "ten"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "ten"), 0, wx.EXPAND) ##box.Hide(btn3) @@ -191,31 +230,31 @@ def makeBorderInBox(win): insideBox = wx.BoxSizer(wx.HORIZONTAL) box2 = wx.BoxSizer(wx.HORIZONTAL) - box2.AddMany([ (wx.Button(win, -1, "one"), 0, wx.EXPAND), - (wx.Button(win, -1, "two"), 0, wx.EXPAND), - (wx.Button(win, -1, "three"), 0, wx.EXPAND), - (wx.Button(win, -1, "four"), 0, wx.EXPAND), - (wx.Button(win, -1, "five"), 0, wx.EXPAND), + box2.AddMany([ (SampleWindow(win, "one"), 0, wx.EXPAND), + (SampleWindow(win, "two"), 0, wx.EXPAND), + (SampleWindow(win, "three"), 0, wx.EXPAND), + (SampleWindow(win, "four"), 0, wx.EXPAND), + (SampleWindow(win, "five"), 0, wx.EXPAND), ]) insideBox.Add(box2, 0, wx.EXPAND) bdr = wx.BoxSizer(wx.HORIZONTAL) - bdr.Add(wx.Button(win, -1, "border"), 1, wx.EXPAND | wx.ALL) + bdr.Add(SampleWindow(win, "border"), 1, wx.EXPAND | wx.ALL) insideBox.Add(bdr, 1, wx.EXPAND | wx.ALL, 20) box3 = wx.BoxSizer(wx.VERTICAL) - box3.AddMany([ (wx.Button(win, -1, "six"), 0, wx.EXPAND), - (wx.Button(win, -1, "seven"), 2, wx.EXPAND), - (wx.Button(win, -1, "eight"), 1, wx.EXPAND), - (wx.Button(win, -1, "nine"), 1, wx.EXPAND), + box3.AddMany([ (SampleWindow(win, "six"), 0, wx.EXPAND), + (SampleWindow(win, "seven"), 2, wx.EXPAND), + (SampleWindow(win, "eight"), 1, wx.EXPAND), + (SampleWindow(win, "nine"), 1, wx.EXPAND), ]) insideBox.Add(box3, 1, wx.EXPAND) outsideBox = wx.BoxSizer(wx.VERTICAL) - outsideBox.Add(wx.Button(win, -1, "top"), 0, wx.EXPAND) + outsideBox.Add(SampleWindow(win, "top"), 0, wx.EXPAND) outsideBox.Add(insideBox, 1, wx.EXPAND) - outsideBox.Add(wx.Button(win, -1, "bottom"), 0, wx.EXPAND) + outsideBox.Add(SampleWindow(win, "bottom"), 0, wx.EXPAND) return outsideBox @@ -225,16 +264,16 @@ def makeBorderInBox(win): def makeGrid1(win): gs = wx.GridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap - gs.AddMany([ (wx.Button(win, -1, 'one'), 0, wx.EXPAND), - (wx.Button(win, -1, 'two'), 0, wx.EXPAND), - (wx.Button(win, -1, 'three'), 0, wx.EXPAND), - (wx.Button(win, -1, 'four'), 0, wx.EXPAND), - (wx.Button(win, -1, 'five'), 0, wx.EXPAND), + gs.AddMany([ (SampleWindow(win, 'one'), 0, wx.EXPAND), + (SampleWindow(win, 'two'), 0, wx.EXPAND), + (SampleWindow(win, 'three'), 0, wx.EXPAND), + (SampleWindow(win, 'four'), 0, wx.EXPAND), + (SampleWindow(win, 'five'), 0, wx.EXPAND), #(75, 50), - (wx.Button(win, -1, 'six'), 0, wx.EXPAND), - (wx.Button(win, -1, 'seven'), 0, wx.EXPAND), - (wx.Button(win, -1, 'eight'), 0, wx.EXPAND), - (wx.Button(win, -1, 'nine'), 0, wx.EXPAND), + (SampleWindow(win, 'six'), 0, wx.EXPAND), + (SampleWindow(win, 'seven'), 0, wx.EXPAND), + (SampleWindow(win, 'eight'), 0, wx.EXPAND), + (SampleWindow(win, 'nine'), 0, wx.EXPAND), ]) return gs @@ -245,23 +284,23 @@ def makeGrid2(win): gs = wx.GridSizer(3, 3) # rows, cols, hgap, vgap box = wx.BoxSizer(wx.VERTICAL) - box.Add(wx.Button(win, -1, 'A'), 0, wx.EXPAND) - box.Add(wx.Button(win, -1, 'B'), 1, wx.EXPAND) + box.Add(SampleWindow(win, 'A'), 0, wx.EXPAND) + box.Add(SampleWindow(win, 'B'), 1, wx.EXPAND) gs2 = wx.GridSizer(2,2, 4, 4) - gs2.AddMany([ (wx.Button(win, -1, 'C'), 0, wx.EXPAND), - (wx.Button(win, -1, 'E'), 0, wx.EXPAND), - (wx.Button(win, -1, 'F'), 0, wx.EXPAND), - (wx.Button(win, -1, 'G'), 0, wx.EXPAND)]) - - gs.AddMany([ (wx.Button(win, -1, 'one'), 0, wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM), - (wx.Button(win, -1, 'two'), 0, wx.EXPAND), - (wx.Button(win, -1, 'three'), 0, wx.ALIGN_LEFT | wx.ALIGN_BOTTOM), - (wx.Button(win, -1, 'four'), 0, wx.EXPAND), - (wx.Button(win, -1, 'five'), 0, wx.ALIGN_CENTER), - (wx.Button(win, -1, 'six'), 0, wx.EXPAND), + gs2.AddMany([ (SampleWindow(win, 'C'), 0, wx.EXPAND), + (SampleWindow(win, 'E'), 0, wx.EXPAND), + (SampleWindow(win, 'F'), 0, wx.EXPAND), + (SampleWindow(win, 'G'), 0, wx.EXPAND)]) + + gs.AddMany([ (SampleWindow(win, 'one'), 0, wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM), + (SampleWindow(win, 'two'), 0, wx.EXPAND), + (SampleWindow(win, 'three'), 0, wx.ALIGN_LEFT | wx.ALIGN_BOTTOM), + (SampleWindow(win, 'four'), 0, wx.EXPAND), + (SampleWindow(win, 'five'), 0, wx.ALIGN_CENTER), + (SampleWindow(win, 'six'), 0, wx.EXPAND), (box, 0, wx.EXPAND | wx.ALL, 10), - (wx.Button(win, -1, 'eight'), 0, wx.EXPAND), + (SampleWindow(win, 'eight'), 0, wx.EXPAND), (gs2, 0, wx.EXPAND | wx.ALL, 4), ]) @@ -272,16 +311,16 @@ def makeGrid2(win): def makeGrid3(win): gs = wx.FlexGridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap - gs.AddMany([ (wx.Button(win, -1, 'one'), 0, wx.EXPAND), - (wx.Button(win, -1, 'two'), 0, wx.EXPAND), - (wx.Button(win, -1, 'three'), 0, wx.EXPAND), - (wx.Button(win, -1, 'four'), 0, wx.EXPAND), - #(wxButton(win, 1010, 'five'), 0, wxEXPAND), + gs.AddMany([ (SampleWindow(win, 'one'), 0, wx.EXPAND), + (SampleWindow(win, 'two'), 0, wx.EXPAND), + (SampleWindow(win, 'three'), 0, wx.EXPAND), + (SampleWindow(win, 'four'), 0, wx.EXPAND), + #(SampleWindow(win, 'five'), 0, wx.EXPAND), ((175, 50)), - (wx.Button(win, -1, 'six'), 0, wx.EXPAND), - (wx.Button(win, -1, 'seven'), 0, wx.EXPAND), - (wx.Button(win, -1, 'eight'), 0, wx.EXPAND), - (wx.Button(win, -1, 'nine'), 0, wx.EXPAND), + (SampleWindow(win, 'six'), 0, wx.EXPAND), + (SampleWindow(win, 'seven'), 0, wx.EXPAND), + (SampleWindow(win, 'eight'), 0, wx.EXPAND), + (SampleWindow(win, 'nine'), 0, wx.EXPAND), ]) gs.AddGrowableRow(0) @@ -296,23 +335,23 @@ def makeGrid4(win): bsize = wx.Size(100, 50) gs = wx.GridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap - gs.AddMany([ (wx.Button(win, -1, 'one', bpos, bsize), + gs.AddMany([ (SampleWindow(win, 'one', bpos, bsize), 0, wx.ALIGN_TOP | wx.ALIGN_LEFT ), - (wx.Button(win, -1, 'two', bpos, bsize), + (SampleWindow(win, 'two', bpos, bsize), 0, wx.ALIGN_TOP | wx.ALIGN_CENTER_HORIZONTAL ), - (wx.Button(win, -1, 'three', bpos, bsize), + (SampleWindow(win, 'three', bpos, bsize), 0, wx.ALIGN_TOP | wx.ALIGN_RIGHT ), - (wx.Button(win, -1, 'four', bpos, bsize), + (SampleWindow(win, 'four', bpos, bsize), 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT ), - (wx.Button(win, -1, 'five', bpos, bsize), + (SampleWindow(win, 'five', bpos, bsize), 0, wx.ALIGN_CENTER ), - (wx.Button(win, -1, 'six', bpos, bsize), + (SampleWindow(win, 'six', bpos, bsize), 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT ), - (wx.Button(win, -1, 'seven', bpos, bsize), + (SampleWindow(win, 'seven', bpos, bsize), 0, wx.ALIGN_BOTTOM | wx.ALIGN_LEFT ), - (wx.Button(win, -1, 'eight', bpos, bsize), + (SampleWindow(win, 'eight', bpos, bsize), 0, wx.ALIGN_BOTTOM | wx.ALIGN_CENTER_HORIZONTAL ), - (wx.Button(win, -1, 'nine', bpos, bsize), + (SampleWindow(win, 'nine', bpos, bsize), 0, wx.ALIGN_BOTTOM | wx.ALIGN_RIGHT ), ]) @@ -325,23 +364,23 @@ def makeShapes(win): bsize = wx.Size(100, 50) gs = wx.GridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap - gs.AddMany([ (wx.Button(win, -1, 'one', bpos, bsize), + gs.AddMany([ (SampleWindow(win, 'one', bpos, bsize), 0, wx.SHAPED | wx.ALIGN_TOP | wx.ALIGN_LEFT ), - (wx.Button(win, -1, 'two', bpos, bsize), + (SampleWindow(win, 'two', bpos, bsize), 0, wx.SHAPED | wx.ALIGN_TOP | wx.ALIGN_CENTER_HORIZONTAL ), - (wx.Button(win, -1, 'three', bpos, bsize), + (SampleWindow(win, 'three', bpos, bsize), 0, wx.SHAPED | wx.ALIGN_TOP | wx.ALIGN_RIGHT ), - (wx.Button(win, -1, 'four', bpos, bsize), + (SampleWindow(win, 'four', bpos, bsize), 0, wx.SHAPED | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT ), - (wx.Button(win, -1, 'five', bpos, bsize), + (SampleWindow(win, 'five', bpos, bsize), 0, wx.SHAPED | wx.ALIGN_CENTER ), - (wx.Button(win, -1, 'six', bpos, bsize), + (SampleWindow(win, 'six', bpos, bsize), 0, wx.SHAPED | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT ), - (wx.Button(win, -1, 'seven', bpos, bsize), + (SampleWindow(win, 'seven', bpos, bsize), 0, wx.SHAPED | wx.ALIGN_BOTTOM | wx.ALIGN_LEFT ), - (wx.Button(win, -1, 'eight', bpos, bsize), + (SampleWindow(win, 'eight', bpos, bsize), 0, wx.SHAPED | wx.ALIGN_BOTTOM | wx.ALIGN_CENTER_HORIZONTAL ), - (wx.Button(win, -1, 'nine', bpos, bsize), + (SampleWindow(win, 'nine', bpos, bsize), 0, wx.SHAPED | wx.ALIGN_BOTTOM | wx.ALIGN_RIGHT ), ]) @@ -351,11 +390,11 @@ def makeShapes(win): def makeSimpleBoxShaped(win): box = wx.BoxSizer(wx.HORIZONTAL) - box.Add(wx.Button(win, -1, "one"), 0, wx.EXPAND) - box.Add(wx.Button(win, -1, "two"), 0, wx.EXPAND) - box.Add(wx.Button(win, -1, "three"), 0, wx.EXPAND) - box.Add(wx.Button(win, -1, "four"), 0, wx.EXPAND) - box.Add(wx.Button(win, -1, "five"), 1, wx.SHAPED) + box.Add(SampleWindow(win, "one"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "two"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "three"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "four"), 0, wx.EXPAND) + box.Add(SampleWindow(win, "five"), 1, wx.SHAPED) return box @@ -445,14 +484,14 @@ theTests = [ ("", None, ""), ("Simple Grid", makeGrid1, - "This is an example of the wxGridSizer. In this case all row heights " + "This is an example of the wx.GridSizer. In this case all row heights " "and column widths are kept the same as all the others and all items " "fill their available space. The horizontal and vertical gaps are set to " "2 pixels each." ), ("More Grid Features", makeGrid2, - "This is another example of the wxGridSizer. This one has no gaps in the grid, " + "This is another example of the wx.GridSizer. This one has no gaps in the grid, " "but various cells are given different alignment options and some of them " "hold nested sizers." ), @@ -474,7 +513,7 @@ theTests = [ ("Proportional resize", makeSimpleBoxShaped, "Managed items can preserve their original aspect ratio. The last item has the " - "wxSHAPED flag set and will resize proportional to its original size." + "wx.SHAPED flag set and will resize proportional to its original size." ), ("Proportional resize with Alignments", makeShapes, @@ -487,17 +526,15 @@ theTests = [ class TestFrame(wx.Frame): def __init__(self, parent, title, sizerFunc): wx.Frame.__init__(self, parent, -1, title) - self.Bind(wx.EVT_BUTTON, self.OnButton) p = wx.Panel(self, -1) self.sizer = sizerFunc(p) self.CreateStatusBar() self.SetStatusText("Resize this frame to see how the sizers respond...") - self.sizer.Fit(p) - p.SetAutoLayout(True) p.SetSizer(self.sizer) + self.sizer.Fit(p) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) self.Fit() @@ -505,8 +542,6 @@ class TestFrame(wx.Frame): self.MakeModal(False) self.Destroy() - def OnButton(self, event): - self.Close(True) #---------------------------------------------------------------------- @@ -558,9 +593,6 @@ def runTest(frame, nb, log): return win overview = "" -#wxSizer.__doc__ + '\n' + '-' * 80 + '\n' + \ -#wxBoxSizer.__doc__ + '\n' + '-' * 80 + '\n' + \ -#wxBorderSizer.__doc__ #----------------------------------------------------------------------