2003-12-08 20:23:28 -05:00
|
|
|
# 11/26/2003 - Jeff Grimmett (grimmtooth@softhome.net)
|
|
|
|
#
|
|
|
|
# o Had to do a bit of rework for the demo; there was no panel attached
|
|
|
|
# to the demo window, so all buttons were showing as dark gray on
|
|
|
|
# dark gray. I have no idea why this didn't break before. Robin,
|
|
|
|
# please examine my changes to ensure you approve. It's rather
|
|
|
|
# hackish looking.
|
|
|
|
#
|
|
|
|
|
1999-06-22 03:03:29 -04:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# sizer test code
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
import wx
|
1999-06-22 03:03:29 -04:00
|
|
|
|
2004-04-01 12:44:05 -05:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
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()
|
2004-05-01 22:41:33 -04:00
|
|
|
dc.DrawText(self.text, (sz.width-w)/2, (sz.height-h)/2)
|
2004-04-01 12:44:05 -05:00
|
|
|
|
|
|
|
def OnSize(self, evt):
|
|
|
|
self.Refresh()
|
|
|
|
|
|
|
|
def OnCloseParent(self, evt):
|
|
|
|
p = wx.GetTopLevelParent(self)
|
|
|
|
if p:
|
|
|
|
p.Close()
|
|
|
|
|
|
|
|
def DoGetBestSize(self):
|
|
|
|
return self.bestsize
|
|
|
|
|
|
|
|
|
1999-06-22 03:03:29 -04:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeSimpleBox1(win):
|
2003-12-08 20:23:28 -05:00
|
|
|
box = wx.BoxSizer(wx.HORIZONTAL)
|
2004-04-01 12:44:05 -05:00
|
|
|
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)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
|
|
|
return box
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeSimpleBox2(win):
|
2003-12-08 20:23:28 -05:00
|
|
|
box = wx.BoxSizer(wx.VERTICAL)
|
2004-04-01 12:44:05 -05:00
|
|
|
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)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
|
|
|
return box
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeSimpleBox3(win):
|
2003-12-08 20:23:28 -05:00
|
|
|
box = wx.BoxSizer(wx.HORIZONTAL)
|
2004-04-01 12:44:05 -05:00
|
|
|
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)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
|
|
|
return box
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeSimpleBox4(win):
|
2003-12-08 20:23:28 -05:00
|
|
|
box = wx.BoxSizer(wx.HORIZONTAL)
|
2004-04-01 12:44:05 -05:00
|
|
|
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)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
|
|
|
return box
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeSimpleBox5(win):
|
2003-12-08 20:23:28 -05:00
|
|
|
box = wx.BoxSizer(wx.HORIZONTAL)
|
2004-04-01 12:44:05 -05:00
|
|
|
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)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
|
|
|
return box
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeSimpleBox6(win):
|
2003-12-08 20:23:28 -05:00
|
|
|
box = wx.BoxSizer(wx.HORIZONTAL)
|
2004-04-01 12:44:05 -05:00
|
|
|
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)
|
1999-09-30 03:11:20 -04:00
|
|
|
|
|
|
|
return box
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeSimpleBox7(win):
|
2004-01-13 15:33:49 -05:00
|
|
|
box = wx.BoxSizer(wx.HORIZONTAL)
|
2004-04-01 12:44:05 -05:00
|
|
|
box.Add(SampleWindow(win, "one"), 0, wx.EXPAND)
|
|
|
|
box.Add(SampleWindow(win, "two"), 0, wx.EXPAND)
|
|
|
|
box.Add(SampleWindow(win, "three"), 0, wx.EXPAND)
|
2004-01-13 15:33:49 -05:00
|
|
|
box.Add((60, 20), 0, wx.EXPAND)
|
2004-04-01 12:44:05 -05:00
|
|
|
box.Add(SampleWindow(win, "five"), 1, wx.EXPAND)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
|
|
|
return box
|
|
|
|
|
1999-10-22 22:33:44 -04:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeSimpleBox8(win):
|
2004-01-20 18:26:57 -05:00
|
|
|
box = wx.BoxSizer(wx.VERTICAL)
|
2004-04-01 12:44:05 -05:00
|
|
|
box.Add(SampleWindow(win, "one"), 0, wx.EXPAND)
|
2003-11-22 17:57:49 -05:00
|
|
|
box.Add((0,0), 1)
|
2004-04-01 12:44:05 -05:00
|
|
|
box.Add(SampleWindow(win, "two"), 0, wx.ALIGN_CENTER)
|
2003-11-22 17:57:49 -05:00
|
|
|
box.Add((0,0), 1)
|
2004-04-01 12:44:05 -05:00
|
|
|
box.Add(SampleWindow(win, "three"), 0, wx.EXPAND)
|
|
|
|
box.Add(SampleWindow(win, "four"), 0, wx.EXPAND)
|
|
|
|
# box.Add(SampleWindow(win, "five"), 1, wx.EXPAND)
|
1999-10-22 22:33:44 -04:00
|
|
|
|
|
|
|
return box
|
|
|
|
|
1999-06-22 03:03:29 -04:00
|
|
|
#----------------------------------------------------------------------
|
1999-09-30 03:11:20 -04:00
|
|
|
#----------------------------------------------------------------------
|
1999-06-22 03:03:29 -04:00
|
|
|
|
|
|
|
def makeSimpleBorder1(win):
|
2003-12-08 20:23:28 -05:00
|
|
|
bdr = wx.BoxSizer(wx.HORIZONTAL)
|
2004-04-01 12:44:05 -05:00
|
|
|
btn = SampleWindow(win, "border")
|
2003-12-08 20:23:28 -05:00
|
|
|
btn.SetSize((80, 80))
|
|
|
|
bdr.Add(btn, 1, wx.EXPAND|wx.ALL, 15)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
|
|
|
return bdr
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeSimpleBorder2(win):
|
2003-12-08 20:23:28 -05:00
|
|
|
bdr = wx.BoxSizer(wx.HORIZONTAL)
|
2004-04-01 12:44:05 -05:00
|
|
|
btn = SampleWindow(win, "border")
|
2003-12-08 20:23:28 -05:00
|
|
|
btn.SetSize((80, 80))
|
|
|
|
bdr.Add(btn, 1, wx.EXPAND | wx.EAST | wx.WEST, 15)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
|
|
|
return bdr
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeSimpleBorder3(win):
|
2003-12-08 20:23:28 -05:00
|
|
|
bdr = wx.BoxSizer(wx.HORIZONTAL)
|
2004-04-01 12:44:05 -05:00
|
|
|
btn = SampleWindow(win, "border")
|
2003-12-08 20:23:28 -05:00
|
|
|
btn.SetSize((80, 80))
|
|
|
|
bdr.Add(btn, 1, wx.EXPAND | wx.NORTH | wx.WEST, 15)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
|
|
|
return bdr
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeBoxInBox(win):
|
2003-12-08 20:23:28 -05:00
|
|
|
box = wx.BoxSizer(wx.VERTICAL)
|
|
|
|
|
2004-04-01 12:44:05 -05:00
|
|
|
box.Add(SampleWindow(win, "one"), 0, wx.EXPAND)
|
2003-12-08 20:23:28 -05:00
|
|
|
|
|
|
|
box2 = wx.BoxSizer(wx.HORIZONTAL)
|
2004-04-01 12:44:05 -05:00
|
|
|
box2.Add(SampleWindow(win, "two"), 0, wx.EXPAND)
|
|
|
|
btn3 = SampleWindow(win, "three")
|
2003-12-08 20:23:28 -05:00
|
|
|
box2.Add(btn3, 0, wx.EXPAND)
|
2004-04-01 12:44:05 -05:00
|
|
|
box2.Add(SampleWindow(win, "four"), 0, wx.EXPAND)
|
|
|
|
box2.Add(SampleWindow(win, "five"), 0, wx.EXPAND)
|
2003-12-08 20:23:28 -05:00
|
|
|
|
|
|
|
box3 = wx.BoxSizer(wx.VERTICAL)
|
2004-04-01 12:44:05 -05:00
|
|
|
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),
|
1999-06-22 03:03:29 -04:00
|
|
|
])
|
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
box2.Add(box3, 1, wx.EXPAND)
|
|
|
|
box.Add(box2, 1, wx.EXPAND)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
2004-04-01 12:44:05 -05:00
|
|
|
box.Add(SampleWindow(win, "ten"), 0, wx.EXPAND)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
2003-07-02 19:13:10 -04:00
|
|
|
##box.Hide(btn3)
|
|
|
|
|
1999-06-22 03:03:29 -04:00
|
|
|
return box
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeBoxInBorder(win):
|
2003-12-08 20:23:28 -05:00
|
|
|
bdr = wx.BoxSizer(wx.HORIZONTAL)
|
1999-06-22 03:03:29 -04:00
|
|
|
box = makeSimpleBox3(win)
|
2003-12-08 20:23:28 -05:00
|
|
|
bdr.Add(box, 1, wx.EXPAND | wx.ALL, 15)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
|
|
|
return bdr
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeBorderInBox(win):
|
2003-12-08 20:23:28 -05:00
|
|
|
insideBox = wx.BoxSizer(wx.HORIZONTAL)
|
|
|
|
|
|
|
|
box2 = wx.BoxSizer(wx.HORIZONTAL)
|
2004-04-01 12:44:05 -05:00
|
|
|
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),
|
1999-06-22 11:46:03 -04:00
|
|
|
])
|
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
insideBox.Add(box2, 0, wx.EXPAND)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
bdr = wx.BoxSizer(wx.HORIZONTAL)
|
2004-04-01 12:44:05 -05:00
|
|
|
bdr.Add(SampleWindow(win, "border"), 1, wx.EXPAND | wx.ALL)
|
2003-12-08 20:23:28 -05:00
|
|
|
insideBox.Add(bdr, 1, wx.EXPAND | wx.ALL, 20)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
box3 = wx.BoxSizer(wx.VERTICAL)
|
2004-04-01 12:44:05 -05:00
|
|
|
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),
|
1999-06-22 11:46:03 -04:00
|
|
|
])
|
2003-12-08 20:23:28 -05:00
|
|
|
insideBox.Add(box3, 1, wx.EXPAND)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
outsideBox = wx.BoxSizer(wx.VERTICAL)
|
2004-04-01 12:44:05 -05:00
|
|
|
outsideBox.Add(SampleWindow(win, "top"), 0, wx.EXPAND)
|
2003-12-08 20:23:28 -05:00
|
|
|
outsideBox.Add(insideBox, 1, wx.EXPAND)
|
2004-04-01 12:44:05 -05:00
|
|
|
outsideBox.Add(SampleWindow(win, "bottom"), 0, wx.EXPAND)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
|
|
|
return outsideBox
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
1999-09-30 03:11:20 -04:00
|
|
|
def makeGrid1(win):
|
2003-12-08 20:23:28 -05:00
|
|
|
gs = wx.GridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
|
1999-09-30 03:11:20 -04:00
|
|
|
|
2004-04-01 12:44:05 -05:00
|
|
|
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),
|
1999-09-30 03:11:20 -04:00
|
|
|
#(75, 50),
|
2004-04-01 12:44:05 -05:00
|
|
|
(SampleWindow(win, 'six'), 0, wx.EXPAND),
|
|
|
|
(SampleWindow(win, 'seven'), 0, wx.EXPAND),
|
|
|
|
(SampleWindow(win, 'eight'), 0, wx.EXPAND),
|
|
|
|
(SampleWindow(win, 'nine'), 0, wx.EXPAND),
|
1999-09-30 03:11:20 -04:00
|
|
|
])
|
|
|
|
|
|
|
|
return gs
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeGrid2(win):
|
2003-12-08 20:23:28 -05:00
|
|
|
gs = wx.GridSizer(3, 3) # rows, cols, hgap, vgap
|
|
|
|
|
|
|
|
box = wx.BoxSizer(wx.VERTICAL)
|
2004-04-01 12:44:05 -05:00
|
|
|
box.Add(SampleWindow(win, 'A'), 0, wx.EXPAND)
|
|
|
|
box.Add(SampleWindow(win, 'B'), 1, wx.EXPAND)
|
2003-12-08 20:23:28 -05:00
|
|
|
|
|
|
|
gs2 = wx.GridSizer(2,2, 4, 4)
|
2004-04-01 12:44:05 -05:00
|
|
|
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),
|
2003-12-08 20:23:28 -05:00
|
|
|
(box, 0, wx.EXPAND | wx.ALL, 10),
|
2004-04-01 12:44:05 -05:00
|
|
|
(SampleWindow(win, 'eight'), 0, wx.EXPAND),
|
2003-12-08 20:23:28 -05:00
|
|
|
(gs2, 0, wx.EXPAND | wx.ALL, 4),
|
1999-09-30 03:11:20 -04:00
|
|
|
])
|
|
|
|
|
|
|
|
return gs
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeGrid3(win):
|
2003-12-08 20:23:28 -05:00
|
|
|
gs = wx.FlexGridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
|
1999-09-30 03:11:20 -04:00
|
|
|
|
2004-04-01 12:44:05 -05:00
|
|
|
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),
|
2003-12-08 20:23:28 -05:00
|
|
|
((175, 50)),
|
2004-04-01 12:44:05 -05:00
|
|
|
(SampleWindow(win, 'six'), 0, wx.EXPAND),
|
|
|
|
(SampleWindow(win, 'seven'), 0, wx.EXPAND),
|
|
|
|
(SampleWindow(win, 'eight'), 0, wx.EXPAND),
|
|
|
|
(SampleWindow(win, 'nine'), 0, wx.EXPAND),
|
1999-09-30 03:11:20 -04:00
|
|
|
])
|
|
|
|
|
|
|
|
gs.AddGrowableRow(0)
|
|
|
|
gs.AddGrowableRow(2)
|
|
|
|
gs.AddGrowableCol(1)
|
|
|
|
return gs
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
1999-11-09 18:02:41 -05:00
|
|
|
def makeGrid4(win):
|
2003-12-08 20:23:28 -05:00
|
|
|
bpos = wx.DefaultPosition
|
|
|
|
bsize = wx.Size(100, 50)
|
|
|
|
gs = wx.GridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
|
|
|
|
|
2004-04-01 12:44:05 -05:00
|
|
|
gs.AddMany([ (SampleWindow(win, 'one', bpos, bsize),
|
2003-12-08 20:23:28 -05:00
|
|
|
0, wx.ALIGN_TOP | wx.ALIGN_LEFT ),
|
2004-04-01 12:44:05 -05:00
|
|
|
(SampleWindow(win, 'two', bpos, bsize),
|
2003-12-08 20:23:28 -05:00
|
|
|
0, wx.ALIGN_TOP | wx.ALIGN_CENTER_HORIZONTAL ),
|
2004-04-01 12:44:05 -05:00
|
|
|
(SampleWindow(win, 'three', bpos, bsize),
|
2003-12-08 20:23:28 -05:00
|
|
|
0, wx.ALIGN_TOP | wx.ALIGN_RIGHT ),
|
2004-04-01 12:44:05 -05:00
|
|
|
(SampleWindow(win, 'four', bpos, bsize),
|
2003-12-08 20:23:28 -05:00
|
|
|
0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT ),
|
2004-04-01 12:44:05 -05:00
|
|
|
(SampleWindow(win, 'five', bpos, bsize),
|
2003-12-08 20:23:28 -05:00
|
|
|
0, wx.ALIGN_CENTER ),
|
2004-04-01 12:44:05 -05:00
|
|
|
(SampleWindow(win, 'six', bpos, bsize),
|
2003-12-08 20:23:28 -05:00
|
|
|
0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT ),
|
2004-04-01 12:44:05 -05:00
|
|
|
(SampleWindow(win, 'seven', bpos, bsize),
|
2003-12-08 20:23:28 -05:00
|
|
|
0, wx.ALIGN_BOTTOM | wx.ALIGN_LEFT ),
|
2004-04-01 12:44:05 -05:00
|
|
|
(SampleWindow(win, 'eight', bpos, bsize),
|
2003-12-08 20:23:28 -05:00
|
|
|
0, wx.ALIGN_BOTTOM | wx.ALIGN_CENTER_HORIZONTAL ),
|
2004-04-01 12:44:05 -05:00
|
|
|
(SampleWindow(win, 'nine', bpos, bsize),
|
2003-12-08 20:23:28 -05:00
|
|
|
0, wx.ALIGN_BOTTOM | wx.ALIGN_RIGHT ),
|
1999-11-09 18:02:41 -05:00
|
|
|
])
|
|
|
|
|
|
|
|
return gs
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeShapes(win):
|
2003-12-08 20:23:28 -05:00
|
|
|
bpos = wx.DefaultPosition
|
|
|
|
bsize = wx.Size(100, 50)
|
|
|
|
gs = wx.GridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
|
|
|
|
|
2004-04-01 12:44:05 -05:00
|
|
|
gs.AddMany([ (SampleWindow(win, 'one', bpos, bsize),
|
2003-12-08 20:23:28 -05:00
|
|
|
0, wx.SHAPED | wx.ALIGN_TOP | wx.ALIGN_LEFT ),
|
2004-04-01 12:44:05 -05:00
|
|
|
(SampleWindow(win, 'two', bpos, bsize),
|
2003-12-08 20:23:28 -05:00
|
|
|
0, wx.SHAPED | wx.ALIGN_TOP | wx.ALIGN_CENTER_HORIZONTAL ),
|
2004-04-01 12:44:05 -05:00
|
|
|
(SampleWindow(win, 'three', bpos, bsize),
|
2003-12-08 20:23:28 -05:00
|
|
|
0, wx.SHAPED | wx.ALIGN_TOP | wx.ALIGN_RIGHT ),
|
2004-04-01 12:44:05 -05:00
|
|
|
(SampleWindow(win, 'four', bpos, bsize),
|
2003-12-08 20:23:28 -05:00
|
|
|
0, wx.SHAPED | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT ),
|
2004-04-01 12:44:05 -05:00
|
|
|
(SampleWindow(win, 'five', bpos, bsize),
|
2003-12-08 20:23:28 -05:00
|
|
|
0, wx.SHAPED | wx.ALIGN_CENTER ),
|
2004-04-01 12:44:05 -05:00
|
|
|
(SampleWindow(win, 'six', bpos, bsize),
|
2003-12-08 20:23:28 -05:00
|
|
|
0, wx.SHAPED | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT ),
|
2004-04-01 12:44:05 -05:00
|
|
|
(SampleWindow(win, 'seven', bpos, bsize),
|
2003-12-08 20:23:28 -05:00
|
|
|
0, wx.SHAPED | wx.ALIGN_BOTTOM | wx.ALIGN_LEFT ),
|
2004-04-01 12:44:05 -05:00
|
|
|
(SampleWindow(win, 'eight', bpos, bsize),
|
2003-12-08 20:23:28 -05:00
|
|
|
0, wx.SHAPED | wx.ALIGN_BOTTOM | wx.ALIGN_CENTER_HORIZONTAL ),
|
2004-04-01 12:44:05 -05:00
|
|
|
(SampleWindow(win, 'nine', bpos, bsize),
|
2003-12-08 20:23:28 -05:00
|
|
|
0, wx.SHAPED | wx.ALIGN_BOTTOM | wx.ALIGN_RIGHT ),
|
1999-11-09 18:02:41 -05:00
|
|
|
])
|
|
|
|
|
|
|
|
return gs
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeSimpleBoxShaped(win):
|
2003-12-08 20:23:28 -05:00
|
|
|
box = wx.BoxSizer(wx.HORIZONTAL)
|
2004-04-01 12:44:05 -05:00
|
|
|
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)
|
1999-11-09 18:02:41 -05:00
|
|
|
|
|
|
|
return box
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
1999-06-22 03:03:29 -04:00
|
|
|
theTests = [
|
|
|
|
("Simple horizontal boxes", makeSimpleBox1,
|
|
|
|
"This is a HORIZONTAL box sizer with four non-stretchable buttons held "
|
|
|
|
"within it. Notice that the buttons are added and aligned in the horizontal "
|
|
|
|
"dimension. Also notice that they are fixed size in the horizontal dimension, "
|
|
|
|
"but will stretch vertically."
|
|
|
|
),
|
|
|
|
|
|
|
|
("Simple vertical boxes", makeSimpleBox2,
|
|
|
|
"Exactly the same as the previous sample but using a VERTICAL box sizer "
|
|
|
|
"instead of a HORIZONTAL one."
|
|
|
|
),
|
|
|
|
|
|
|
|
("Add a stretchable", makeSimpleBox3,
|
2003-10-01 20:58:06 -04:00
|
|
|
"We've added one more button with the stretchable flag turned on. Notice "
|
1999-06-22 03:03:29 -04:00
|
|
|
"how it grows to fill the extra space in the otherwise fixed dimension."
|
|
|
|
),
|
|
|
|
|
|
|
|
("More than one stretchable", makeSimpleBox4,
|
|
|
|
"Here there are several items that are stretchable, they all divide up the "
|
|
|
|
"extra space evenly."
|
|
|
|
),
|
|
|
|
|
|
|
|
("Weighting factor", makeSimpleBox5,
|
2003-10-01 20:58:06 -04:00
|
|
|
"This one shows more than one stretchable, but one of them has a weighting "
|
1999-06-22 03:03:29 -04:00
|
|
|
"factor so it gets more of the free space."
|
|
|
|
),
|
|
|
|
|
1999-09-30 03:11:20 -04:00
|
|
|
("Edge Affinity", makeSimpleBox6,
|
|
|
|
"For items that don't completly fill their allotted space, and don't "
|
|
|
|
"stretch, you can specify which side (or the center) they should stay "
|
|
|
|
"attached to."
|
|
|
|
),
|
|
|
|
|
|
|
|
("Spacer", makeSimpleBox7,
|
|
|
|
"You can add empty space to be managed by a Sizer just as if it were a "
|
|
|
|
"window or another Sizer."
|
|
|
|
),
|
|
|
|
|
1999-10-22 22:33:44 -04:00
|
|
|
("Centering in available space", makeSimpleBox8,
|
|
|
|
"This one shows an item that does not expand to fill it's space, but rather"
|
|
|
|
"stays centered within it."
|
|
|
|
),
|
|
|
|
|
1999-06-22 03:03:29 -04:00
|
|
|
# ("Percent Sizer", makeSimpleBox6,
|
2003-12-08 20:23:28 -05:00
|
|
|
# "You can use the wx.BoxSizer like a Percent Sizer. Just make sure that all "
|
1999-06-22 03:03:29 -04:00
|
|
|
# "the weighting factors add up to 100!"
|
|
|
|
# ),
|
|
|
|
|
|
|
|
("", None, ""),
|
|
|
|
|
|
|
|
("Simple border sizer", makeSimpleBorder1,
|
2003-12-08 20:23:28 -05:00
|
|
|
"The wx.BoxSizer can leave empty space around its contents. This one "
|
1999-06-22 03:03:29 -04:00
|
|
|
"gives a border all the way around."
|
|
|
|
),
|
|
|
|
|
|
|
|
("East and West border", makeSimpleBorder2,
|
|
|
|
"You can pick and choose which sides have borders."
|
|
|
|
),
|
|
|
|
|
|
|
|
("North and West border", makeSimpleBorder3,
|
|
|
|
"You can pick and choose which sides have borders."
|
|
|
|
),
|
|
|
|
|
|
|
|
("", None, ""),
|
|
|
|
|
|
|
|
("Boxes inside of boxes", makeBoxInBox,
|
|
|
|
"This one shows nesting of boxes within boxes within boxes, using both "
|
|
|
|
"orientations. Notice also that button seven has a greater weighting "
|
|
|
|
"factor than its siblings."
|
|
|
|
),
|
|
|
|
|
|
|
|
("Boxes inside a Border", makeBoxInBorder,
|
2003-10-01 20:58:06 -04:00
|
|
|
"Sizers of different types can be nested within each other as well. "
|
1999-06-22 03:03:29 -04:00
|
|
|
"Here is a box sizer with several buttons embedded within a border sizer."
|
|
|
|
),
|
|
|
|
|
|
|
|
("Border in a Box", makeBorderInBox,
|
1999-06-22 11:46:03 -04:00
|
|
|
"Another nesting example. This one has Boxes and a Border inside another Box."
|
1999-06-22 03:03:29 -04:00
|
|
|
),
|
|
|
|
|
1999-09-30 03:11:20 -04:00
|
|
|
("", None, ""),
|
|
|
|
|
|
|
|
("Simple Grid", makeGrid1,
|
2004-01-20 18:26:57 -05:00
|
|
|
"This is an example of the wx.GridSizer. In this case all row heights "
|
1999-09-30 03:11:20 -04:00
|
|
|
"and column widths are kept the same as all the others and all items "
|
2003-10-01 20:58:06 -04:00
|
|
|
"fill their available space. The horizontal and vertical gaps are set to "
|
1999-09-30 03:11:20 -04:00
|
|
|
"2 pixels each."
|
|
|
|
),
|
|
|
|
|
|
|
|
("More Grid Features", makeGrid2,
|
2004-01-20 18:26:57 -05:00
|
|
|
"This is another example of the wx.GridSizer. This one has no gaps in the grid, "
|
1999-09-30 03:11:20 -04:00
|
|
|
"but various cells are given different alignment options and some of them "
|
|
|
|
"hold nested sizers."
|
|
|
|
),
|
|
|
|
|
|
|
|
("Flexible Grid", makeGrid3,
|
|
|
|
"This grid allows the rows to have different heights and the columns to have "
|
|
|
|
"different widths. You can also specify rows and columns that are growable, "
|
|
|
|
"which we have done for the first and last row and the middle column for "
|
|
|
|
"this example.\n"
|
|
|
|
"\nThere is also a spacer in the middle cell instead of an actual window."
|
|
|
|
),
|
|
|
|
|
1999-11-09 18:02:41 -05:00
|
|
|
("Grid with Alignment", makeGrid4,
|
|
|
|
"New alignment flags allow for the positioning of items in any corner or centered "
|
|
|
|
"position."
|
|
|
|
),
|
|
|
|
|
|
|
|
("", None, ""),
|
|
|
|
|
|
|
|
("Proportional resize", makeSimpleBoxShaped,
|
|
|
|
"Managed items can preserve their original aspect ratio. The last item has the "
|
2004-01-20 18:26:57 -05:00
|
|
|
"wx.SHAPED flag set and will resize proportional to its original size."
|
1999-11-09 18:02:41 -05:00
|
|
|
),
|
|
|
|
|
|
|
|
("Proportional resize with Alignments", makeShapes,
|
|
|
|
"This one shows various alignments as well as proportional resizing for all items."
|
|
|
|
),
|
|
|
|
|
1999-06-22 03:03:29 -04:00
|
|
|
]
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
class TestFrame(wx.Frame):
|
1999-06-22 03:03:29 -04:00
|
|
|
def __init__(self, parent, title, sizerFunc):
|
2003-12-08 20:23:28 -05:00
|
|
|
wx.Frame.__init__(self, parent, -1, title)
|
|
|
|
|
|
|
|
p = wx.Panel(self, -1)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
self.sizer = sizerFunc(p)
|
1999-06-22 03:03:29 -04:00
|
|
|
self.CreateStatusBar()
|
1999-06-27 23:10:35 -04:00
|
|
|
self.SetStatusText("Resize this frame to see how the sizers respond...")
|
2003-12-08 20:23:28 -05:00
|
|
|
self.sizer.Fit(p)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
p.SetSizer(self.sizer)
|
|
|
|
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
|
|
|
|
self.Fit()
|
1999-06-22 03:03:29 -04:00
|
|
|
|
|
|
|
def OnCloseWindow(self, event):
|
2003-03-25 01:35:27 -05:00
|
|
|
self.MakeModal(False)
|
1999-06-22 03:03:29 -04:00
|
|
|
self.Destroy()
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
class TestSelectionPanel(wx.Panel):
|
1999-06-22 03:03:29 -04:00
|
|
|
def __init__(self, parent, frame):
|
2003-12-08 20:23:28 -05:00
|
|
|
wx.Panel.__init__(self, parent, -1)
|
1999-06-22 03:03:29 -04:00
|
|
|
self.frame = frame
|
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
self.list = wx.ListBox(self, -1,
|
|
|
|
wx.DLG_PNT(self, 10, 10), wx.DLG_SZE(self, 100, 100),
|
1999-06-22 03:03:29 -04:00
|
|
|
[])
|
2003-12-08 20:23:28 -05:00
|
|
|
self.Bind(wx.EVT_LISTBOX, self.OnSelect, id=self.list.GetId())
|
|
|
|
self.Bind(wx.EVT_LISTBOX_DCLICK, self.OnDClick, id=self.list.GetId())
|
1999-06-22 03:03:29 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
self.btn = wx.Button(self, -1, "Try it!", wx.DLG_PNT(self, 120, 10)).SetDefault()
|
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnDClick)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
self.text = wx.TextCtrl(self, -1, "",
|
|
|
|
wx.DLG_PNT(self, 10, 115),
|
|
|
|
wx.DLG_SZE(self, 200, 50),
|
|
|
|
wx.TE_MULTILINE | wx.TE_READONLY)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
|
|
|
for item in theTests:
|
|
|
|
self.list.Append(item[0])
|
|
|
|
|
|
|
|
|
|
|
|
def OnSelect(self, event):
|
|
|
|
pos = self.list.GetSelection()
|
|
|
|
self.text.SetValue(theTests[pos][2])
|
|
|
|
|
|
|
|
|
|
|
|
def OnDClick(self, event):
|
|
|
|
pos = self.list.GetSelection()
|
|
|
|
title = theTests[pos][0]
|
|
|
|
func = theTests[pos][1]
|
|
|
|
|
|
|
|
if func:
|
|
|
|
win = TestFrame(self, title, func)
|
2003-12-08 20:23:28 -05:00
|
|
|
win.CentreOnParent(wx.BOTH)
|
2003-03-25 01:35:27 -05:00
|
|
|
win.Show(True)
|
|
|
|
win.MakeModal(True)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
|
|
|
win = TestSelectionPanel(nb, frame)
|
|
|
|
return win
|
|
|
|
|
1999-09-30 03:11:20 -04:00
|
|
|
overview = ""
|
1999-06-22 03:03:29 -04:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
class MainFrame(wx.Frame):
|
1999-06-22 03:03:29 -04:00
|
|
|
def __init__(self):
|
2003-12-08 20:23:28 -05:00
|
|
|
wx.Frame.__init__(self, None, -1, "Testing...")
|
1999-06-22 03:03:29 -04:00
|
|
|
|
2003-03-25 01:35:27 -05:00
|
|
|
self.CreateStatusBar()
|
2003-12-08 20:23:28 -05:00
|
|
|
mainmenu = wx.MenuBar()
|
|
|
|
menu = wx.Menu()
|
2003-03-25 01:35:27 -05:00
|
|
|
menu.Append(200, 'E&xit', 'Get the heck outta here!')
|
|
|
|
mainmenu.Append(menu, "&File")
|
|
|
|
self.SetMenuBar(mainmenu)
|
2003-12-08 20:23:28 -05:00
|
|
|
self.Bind(wx.EVT_MENU, self.OnExit, id=200)
|
1999-09-30 03:11:20 -04:00
|
|
|
self.panel = TestSelectionPanel(self, self)
|
2003-12-08 20:23:28 -05:00
|
|
|
self.SetSize((400, 380))
|
|
|
|
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
|
|
|
def OnCloseWindow(self, event):
|
|
|
|
self.Destroy()
|
|
|
|
|
|
|
|
def OnExit(self, event):
|
2003-03-25 01:35:27 -05:00
|
|
|
self.Close(True)
|
1999-06-22 03:03:29 -04:00
|
|
|
|
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
class TestApp(wx.App):
|
1999-06-22 03:03:29 -04:00
|
|
|
def OnInit(self):
|
|
|
|
frame = MainFrame()
|
2003-03-25 01:35:27 -05:00
|
|
|
frame.Show(True)
|
1999-06-22 03:03:29 -04:00
|
|
|
self.SetTopWindow(frame)
|
2003-03-25 01:35:27 -05:00
|
|
|
return True
|
1999-06-22 03:03:29 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
app = TestApp(False)
|
1999-06-22 03:03:29 -04:00
|
|
|
app.MainLoop()
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|