1999-06-22 07:03:29 +00:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# sizer test code
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
1999-09-30 07:11:20 +00:00
|
|
|
from wxPython.wx import *
|
|
|
|
from wxPython.lib.grids import wxGridSizer, wxFlexGridSizer
|
1999-06-22 07:03:29 +00:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeSimpleBox1(win):
|
|
|
|
box = wxBoxSizer(wxHORIZONTAL)
|
1999-10-06 06:22:25 +00:00
|
|
|
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(wxButton(win, 1010, "four"), 0, wxEXPAND)
|
1999-06-22 07:03:29 +00:00
|
|
|
|
|
|
|
return box
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeSimpleBox2(win):
|
|
|
|
box = wxBoxSizer(wxVERTICAL)
|
1999-10-06 06:22:25 +00:00
|
|
|
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(wxButton(win, 1010, "four"), 0, wxEXPAND)
|
1999-06-22 07:03:29 +00:00
|
|
|
|
|
|
|
return box
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeSimpleBox3(win):
|
|
|
|
box = wxBoxSizer(wxHORIZONTAL)
|
1999-10-06 06:22:25 +00:00
|
|
|
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(wxButton(win, 1010, "four"), 0, wxEXPAND)
|
|
|
|
box.Add(wxButton(win, 1010, "five"), 1, wxEXPAND)
|
1999-06-22 07:03:29 +00:00
|
|
|
|
|
|
|
return box
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeSimpleBox4(win):
|
|
|
|
box = wxBoxSizer(wxHORIZONTAL)
|
1999-10-06 06:22:25 +00:00
|
|
|
box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
|
|
|
|
box.Add(wxButton(win, 1010, "two"), 0, wxEXPAND)
|
|
|
|
box.Add(wxButton(win, 1010, "three"), 1, wxEXPAND)
|
|
|
|
box.Add(wxButton(win, 1010, "four"), 1, wxEXPAND)
|
|
|
|
box.Add(wxButton(win, 1010, "five"), 1, wxEXPAND)
|
1999-06-22 07:03:29 +00:00
|
|
|
|
|
|
|
return box
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeSimpleBox5(win):
|
|
|
|
box = wxBoxSizer(wxHORIZONTAL)
|
1999-10-06 06:22:25 +00:00
|
|
|
box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
|
|
|
|
box.Add(wxButton(win, 1010, "two"), 0, wxEXPAND)
|
|
|
|
box.Add(wxButton(win, 1010, "three"), 3, wxEXPAND)
|
|
|
|
box.Add(wxButton(win, 1010, "four"), 1, wxEXPAND)
|
|
|
|
box.Add(wxButton(win, 1010, "five"), 1, wxEXPAND)
|
1999-06-22 07:03:29 +00:00
|
|
|
|
|
|
|
return box
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeSimpleBox6(win):
|
1999-09-30 07:11:20 +00:00
|
|
|
box = wxBoxSizer(wxHORIZONTAL)
|
|
|
|
box.Add(wxButton(win, 1010, "one"), 1, wxALIGN_TOP)
|
1999-10-06 06:22:25 +00:00
|
|
|
box.Add(wxButton(win, 1010, "two"), 1, wxEXPAND)
|
1999-11-09 23:02:41 +00:00
|
|
|
box.Add(wxButton(win, 1010, "three"), 1, wxALIGN_CENTER)
|
1999-10-06 06:22:25 +00:00
|
|
|
box.Add(wxButton(win, 1010, "four"), 1, wxEXPAND)
|
1999-09-30 07:11:20 +00:00
|
|
|
box.Add(wxButton(win, 1010, "five"), 1, wxALIGN_BOTTOM)
|
|
|
|
|
|
|
|
return box
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeSimpleBox7(win):
|
|
|
|
box = wxBoxSizer(wxHORIZONTAL)
|
1999-10-06 06:22:25 +00:00
|
|
|
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)
|
1999-06-22 07:03:29 +00:00
|
|
|
|
|
|
|
return box
|
|
|
|
|
1999-10-23 02:33:44 +00:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeSimpleBox8(win):
|
|
|
|
box = wxBoxSizer(wxVERTICAL)
|
|
|
|
box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
|
|
|
|
box.Add(0,0, 1)
|
1999-11-09 23:02:41 +00:00
|
|
|
box.Add(wxButton(win, 1010, "two"), 0, wxALIGN_CENTER)
|
1999-10-23 02:33:44 +00:00
|
|
|
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)
|
|
|
|
|
|
|
|
return box
|
|
|
|
|
1999-06-22 07:03:29 +00:00
|
|
|
#----------------------------------------------------------------------
|
1999-09-30 07:11:20 +00:00
|
|
|
#----------------------------------------------------------------------
|
1999-06-22 07:03:29 +00:00
|
|
|
|
|
|
|
def makeSimpleBorder1(win):
|
1999-09-30 07:11:20 +00:00
|
|
|
bdr = wxBoxSizer(wxHORIZONTAL)
|
1999-06-22 07:03:29 +00:00
|
|
|
btn = wxButton(win, 1010, "border")
|
|
|
|
btn.SetSize(wxSize(80, 80))
|
1999-10-06 06:22:25 +00:00
|
|
|
bdr.Add(btn, 1, wxEXPAND|wxALL, 15)
|
1999-06-22 07:03:29 +00:00
|
|
|
|
|
|
|
return bdr
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeSimpleBorder2(win):
|
1999-09-30 07:11:20 +00:00
|
|
|
bdr = wxBoxSizer(wxHORIZONTAL)
|
1999-06-22 07:03:29 +00:00
|
|
|
btn = wxButton(win, 1010, "border")
|
|
|
|
btn.SetSize(wxSize(80, 80))
|
1999-10-06 06:22:25 +00:00
|
|
|
bdr.Add(btn, 1, wxEXPAND | wxEAST | wxWEST, 15)
|
1999-06-22 07:03:29 +00:00
|
|
|
|
|
|
|
return bdr
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeSimpleBorder3(win):
|
1999-09-30 07:11:20 +00:00
|
|
|
bdr = wxBoxSizer(wxHORIZONTAL)
|
1999-06-22 07:03:29 +00:00
|
|
|
btn = wxButton(win, 1010, "border")
|
|
|
|
btn.SetSize(wxSize(80, 80))
|
1999-10-06 06:22:25 +00:00
|
|
|
bdr.Add(btn, 1, wxEXPAND | wxNORTH | wxWEST, 15)
|
1999-06-22 07:03:29 +00:00
|
|
|
|
|
|
|
return bdr
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeBoxInBox(win):
|
|
|
|
box = wxBoxSizer(wxVERTICAL)
|
|
|
|
|
1999-10-06 06:22:25 +00:00
|
|
|
box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
|
1999-06-22 07:03:29 +00:00
|
|
|
|
|
|
|
box2 = wxBoxSizer(wxHORIZONTAL)
|
1999-10-06 06:22:25 +00:00
|
|
|
box2.AddMany([ (wxButton(win, 1010, "two"), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, "three"), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, "four"), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, "five"), 0, wxEXPAND),
|
1999-07-31 07:56:15 +00:00
|
|
|
])
|
1999-06-22 07:03:29 +00:00
|
|
|
|
|
|
|
box3 = wxBoxSizer(wxVERTICAL)
|
1999-10-06 06:22:25 +00:00
|
|
|
box3.AddMany([ (wxButton(win, 1010, "six"), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, "seven"), 2, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, "eight"), 1, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, "nine"), 1, wxEXPAND),
|
1999-06-22 07:03:29 +00:00
|
|
|
])
|
|
|
|
|
1999-10-06 06:22:25 +00:00
|
|
|
box2.Add(box3, 1, wxEXPAND)
|
|
|
|
box.Add(box2, 1, wxEXPAND)
|
1999-06-22 07:03:29 +00:00
|
|
|
|
1999-10-06 06:22:25 +00:00
|
|
|
box.Add(wxButton(win, 1010, "ten"), 0, wxEXPAND)
|
1999-06-22 07:03:29 +00:00
|
|
|
|
|
|
|
return box
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeBoxInBorder(win):
|
1999-09-30 07:11:20 +00:00
|
|
|
bdr = wxBoxSizer(wxHORIZONTAL)
|
1999-06-22 07:03:29 +00:00
|
|
|
box = makeSimpleBox3(win)
|
1999-10-06 06:22:25 +00:00
|
|
|
bdr.Add(box, 1, wxEXPAND | wxALL, 15)
|
1999-06-22 07:03:29 +00:00
|
|
|
|
|
|
|
return bdr
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeBorderInBox(win):
|
|
|
|
insideBox = wxBoxSizer(wxHORIZONTAL)
|
1999-06-22 15:46:03 +00:00
|
|
|
|
|
|
|
box2 = wxBoxSizer(wxHORIZONTAL)
|
1999-10-06 06:22:25 +00:00
|
|
|
box2.AddMany([ (wxButton(win, 1010, "one"), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, "two"), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, "three"), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, "four"), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, "five"), 0, wxEXPAND),
|
1999-06-22 15:46:03 +00:00
|
|
|
])
|
|
|
|
|
1999-10-06 06:22:25 +00:00
|
|
|
insideBox.Add(box2, 0, wxEXPAND)
|
1999-06-22 07:03:29 +00:00
|
|
|
|
1999-09-30 07:11:20 +00:00
|
|
|
bdr = wxBoxSizer(wxHORIZONTAL)
|
1999-10-06 06:22:25 +00:00
|
|
|
bdr.Add(wxButton(win, 1010, "border"), 1, wxEXPAND | wxALL)
|
|
|
|
insideBox.Add(bdr, 1, wxEXPAND | wxALL, 20)
|
1999-06-22 07:03:29 +00:00
|
|
|
|
|
|
|
box3 = wxBoxSizer(wxVERTICAL)
|
1999-10-06 06:22:25 +00:00
|
|
|
box3.AddMany([ (wxButton(win, 1010, "six"), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, "seven"), 2, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, "eight"), 1, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, "nine"), 1, wxEXPAND),
|
1999-06-22 15:46:03 +00:00
|
|
|
])
|
1999-10-06 06:22:25 +00:00
|
|
|
insideBox.Add(box3, 1, wxEXPAND)
|
1999-06-22 07:03:29 +00:00
|
|
|
|
|
|
|
outsideBox = wxBoxSizer(wxVERTICAL)
|
1999-10-06 06:22:25 +00:00
|
|
|
outsideBox.Add(wxButton(win, 1010, "top"), 0, wxEXPAND)
|
|
|
|
outsideBox.Add(insideBox, 1, wxEXPAND)
|
|
|
|
outsideBox.Add(wxButton(win, 1010, "bottom"), 0, wxEXPAND)
|
1999-06-22 07:03:29 +00:00
|
|
|
|
|
|
|
return outsideBox
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
1999-09-30 07:11:20 +00:00
|
|
|
def makeGrid1(win):
|
|
|
|
gs = wxGridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
|
|
|
|
|
1999-10-06 06:22:25 +00:00
|
|
|
gs.AddMany([ (wxButton(win, 1010, 'one'), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, 'two'), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, 'three'), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, 'four'), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, 'five'), 0, wxEXPAND),
|
1999-09-30 07:11:20 +00:00
|
|
|
#(75, 50),
|
1999-10-06 06:22:25 +00:00
|
|
|
(wxButton(win, 1010, 'six'), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, 'seven'), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, 'eight'), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, 'nine'), 0, wxEXPAND),
|
1999-09-30 07:11:20 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
return gs
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeGrid2(win):
|
|
|
|
gs = wxGridSizer(3, 3) # rows, cols, hgap, vgap
|
|
|
|
|
|
|
|
box = wxBoxSizer(wxVERTICAL)
|
1999-10-06 06:22:25 +00:00
|
|
|
box.Add(wxButton(win, 1010, 'A'), 0, wxEXPAND)
|
|
|
|
box.Add(wxButton(win, 1010, 'B'), 1, wxEXPAND)
|
1999-09-30 07:11:20 +00:00
|
|
|
|
|
|
|
gs2 = wxGridSizer(2,2, 4, 4)
|
1999-10-06 06:22:25 +00:00
|
|
|
gs2.AddMany([ (wxButton(win, 1010, 'C'), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, 'E'), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, 'F'), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, 'G'), 0, wxEXPAND)])
|
1999-09-30 07:11:20 +00:00
|
|
|
|
|
|
|
gs.AddMany([ (wxButton(win, 1010, 'one'), 0, wxALIGN_RIGHT | wxALIGN_BOTTOM),
|
1999-10-06 06:22:25 +00:00
|
|
|
(wxButton(win, 1010, 'two'), 0, wxEXPAND),
|
1999-09-30 07:11:20 +00:00
|
|
|
(wxButton(win, 1010, 'three'), 0, wxALIGN_LEFT | wxALIGN_BOTTOM),
|
1999-10-06 06:22:25 +00:00
|
|
|
(wxButton(win, 1010, 'four'), 0, wxEXPAND),
|
1999-11-09 23:02:41 +00:00
|
|
|
(wxButton(win, 1010, 'five'), 0, wxALIGN_CENTER),
|
1999-10-06 06:22:25 +00:00
|
|
|
(wxButton(win, 1010, 'six'), 0, wxEXPAND),
|
|
|
|
(box, 0, wxEXPAND | wxALL, 10),
|
|
|
|
(wxButton(win, 1010, 'eight'), 0, wxEXPAND),
|
|
|
|
(gs2, 0, wxEXPAND | wxALL, 4),
|
1999-09-30 07:11:20 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
return gs
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeGrid3(win):
|
|
|
|
gs = wxFlexGridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
|
|
|
|
|
1999-10-06 06:22:25 +00:00
|
|
|
gs.AddMany([ (wxButton(win, 1010, 'one'), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, 'two'), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, 'three'), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, 'four'), 0, wxEXPAND),
|
|
|
|
#(wxButton(win, 1010, 'five'), 0, wxEXPAND),
|
1999-09-30 07:11:20 +00:00
|
|
|
(175, 50),
|
1999-10-06 06:22:25 +00:00
|
|
|
(wxButton(win, 1010, 'six'), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, 'seven'), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, 'eight'), 0, wxEXPAND),
|
|
|
|
(wxButton(win, 1010, 'nine'), 0, wxEXPAND),
|
1999-09-30 07:11:20 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
gs.AddGrowableRow(0)
|
|
|
|
gs.AddGrowableRow(2)
|
|
|
|
gs.AddGrowableCol(1)
|
|
|
|
return gs
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
1999-11-09 23:02:41 +00:00
|
|
|
def makeGrid4(win):
|
|
|
|
bpos = wxDefaultPosition
|
|
|
|
bsize = wxSize(100, 50)
|
|
|
|
gs = wxGridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
|
|
|
|
|
|
|
|
gs.AddMany([ (wxButton(win, 1010, 'one', bpos, bsize),
|
|
|
|
0, wxALIGN_TOP | wxALIGN_LEFT ),
|
|
|
|
(wxButton(win, 1010, 'two', bpos, bsize),
|
|
|
|
0, wxALIGN_TOP | wxALIGN_CENTER_HORIZONTAL ),
|
|
|
|
(wxButton(win, 1010, 'three', bpos, bsize),
|
|
|
|
0, wxALIGN_TOP | wxALIGN_RIGHT ),
|
|
|
|
(wxButton(win, 1010, 'four', bpos, bsize),
|
|
|
|
0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT ),
|
|
|
|
(wxButton(win, 1010, 'five', bpos, bsize),
|
|
|
|
0, wxALIGN_CENTER ),
|
|
|
|
(wxButton(win, 1010, 'six', bpos, bsize),
|
|
|
|
0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT ),
|
|
|
|
(wxButton(win, 1010, 'seven', bpos, bsize),
|
|
|
|
0, wxALIGN_BOTTOM | wxALIGN_LEFT ),
|
|
|
|
(wxButton(win, 1010, 'eight', bpos, bsize),
|
|
|
|
0, wxALIGN_BOTTOM | wxALIGN_CENTER_HORIZONTAL ),
|
|
|
|
(wxButton(win, 1010, 'nine', bpos, bsize),
|
|
|
|
0, wxALIGN_BOTTOM | wxALIGN_RIGHT ),
|
|
|
|
])
|
|
|
|
|
|
|
|
return gs
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeShapes(win):
|
|
|
|
bpos = wxDefaultPosition
|
|
|
|
bsize = wxSize(100, 50)
|
|
|
|
gs = wxGridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
|
|
|
|
|
|
|
|
gs.AddMany([ (wxButton(win, 1010, 'one', bpos, bsize),
|
|
|
|
0, wxSHAPED | wxALIGN_TOP | wxALIGN_LEFT ),
|
|
|
|
(wxButton(win, 1010, 'two', bpos, bsize),
|
|
|
|
0, wxSHAPED | wxALIGN_TOP | wxALIGN_CENTER_HORIZONTAL ),
|
|
|
|
(wxButton(win, 1010, 'three', bpos, bsize),
|
|
|
|
0, wxSHAPED | wxALIGN_TOP | wxALIGN_RIGHT ),
|
|
|
|
(wxButton(win, 1010, 'four', bpos, bsize),
|
|
|
|
0, wxSHAPED | wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT ),
|
|
|
|
(wxButton(win, 1010, 'five', bpos, bsize),
|
|
|
|
0, wxSHAPED | wxALIGN_CENTER ),
|
|
|
|
(wxButton(win, 1010, 'six', bpos, bsize),
|
|
|
|
0, wxSHAPED | wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT ),
|
|
|
|
(wxButton(win, 1010, 'seven', bpos, bsize),
|
|
|
|
0, wxSHAPED | wxALIGN_BOTTOM | wxALIGN_LEFT ),
|
|
|
|
(wxButton(win, 1010, 'eight', bpos, bsize),
|
|
|
|
0, wxSHAPED | wxALIGN_BOTTOM | wxALIGN_CENTER_HORIZONTAL ),
|
|
|
|
(wxButton(win, 1010, 'nine', bpos, bsize),
|
|
|
|
0, wxSHAPED | wxALIGN_BOTTOM | wxALIGN_RIGHT ),
|
|
|
|
])
|
|
|
|
|
|
|
|
return gs
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def makeSimpleBoxShaped(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(wxButton(win, 1010, "four"), 0, wxEXPAND)
|
|
|
|
box.Add(wxButton(win, 1010, "five"), 1, wxSHAPED)
|
|
|
|
|
|
|
|
return box
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
1999-06-22 07:03:29 +00: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,
|
|
|
|
"We've added one more button with the strechable flag turned on. Notice "
|
|
|
|
"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,
|
|
|
|
"This one shows more than one strechable, but one of them has a weighting "
|
|
|
|
"factor so it gets more of the free space."
|
|
|
|
),
|
|
|
|
|
1999-09-30 07:11:20 +00: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-23 02:33:44 +00: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 07:03:29 +00:00
|
|
|
# ("Percent Sizer", makeSimpleBox6,
|
|
|
|
# "You can use the wxBoxSizer like a Percent Sizer. Just make sure that all "
|
|
|
|
# "the weighting factors add up to 100!"
|
|
|
|
# ),
|
|
|
|
|
|
|
|
("", None, ""),
|
|
|
|
|
|
|
|
("Simple border sizer", makeSimpleBorder1,
|
1999-11-09 23:02:41 +00:00
|
|
|
"The wxBoxSizer can leave empty space around its contents. This one "
|
1999-06-22 07:03:29 +00: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,
|
|
|
|
"Sizers of different types can be nested withing each other as well. "
|
|
|
|
"Here is a box sizer with several buttons embedded within a border sizer."
|
|
|
|
),
|
|
|
|
|
|
|
|
("Border in a Box", makeBorderInBox,
|
1999-06-22 15:46:03 +00:00
|
|
|
"Another nesting example. This one has Boxes and a Border inside another Box."
|
1999-06-22 07:03:29 +00:00
|
|
|
),
|
|
|
|
|
1999-09-30 07:11:20 +00:00
|
|
|
("", None, ""),
|
|
|
|
|
|
|
|
("Simple Grid", makeGrid1,
|
|
|
|
"This is an example of the wxGridSizer. 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 horzontal 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, "
|
|
|
|
"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 23:02:41 +00: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 "
|
|
|
|
"wxSHAPED flag set and will resize proportional to its origingal size."
|
|
|
|
),
|
|
|
|
|
|
|
|
("Proportional resize with Alignments", makeShapes,
|
|
|
|
"This one shows various alignments as well as proportional resizing for all items."
|
|
|
|
),
|
|
|
|
|
1999-06-22 07:03:29 +00:00
|
|
|
]
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
class TestFrame(wxFrame):
|
|
|
|
def __init__(self, parent, title, sizerFunc):
|
|
|
|
wxFrame.__init__(self, parent, -1, title)
|
|
|
|
EVT_BUTTON(self, 1010, self.OnButton)
|
|
|
|
|
|
|
|
self.sizer = sizerFunc(self)
|
|
|
|
self.CreateStatusBar()
|
1999-06-28 03:10:35 +00:00
|
|
|
self.SetStatusText("Resize this frame to see how the sizers respond...")
|
1999-09-30 07:11:20 +00:00
|
|
|
self.sizer.Fit(self)
|
1999-06-22 07:03:29 +00:00
|
|
|
|
1999-09-30 07:11:20 +00:00
|
|
|
self.SetAutoLayout(true)
|
|
|
|
self.SetSizer(self.sizer)
|
2000-07-15 19:51:35 +00:00
|
|
|
EVT_CLOSE(self, self.OnCloseWindow)
|
1999-06-22 07:03:29 +00:00
|
|
|
|
|
|
|
def OnCloseWindow(self, event):
|
|
|
|
self.MakeModal(false)
|
|
|
|
self.Destroy()
|
|
|
|
|
|
|
|
def OnButton(self, event):
|
|
|
|
self.Close(true)
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestSelectionPanel(wxPanel):
|
|
|
|
def __init__(self, parent, frame):
|
|
|
|
wxPanel.__init__(self, parent, -1)
|
|
|
|
self.frame = frame
|
|
|
|
|
|
|
|
self.list = wxListBox(self, 401,
|
1999-09-30 07:11:20 +00:00
|
|
|
wxDLG_PNT(self, 10, 10), wxDLG_SZE(self, 100, 100),
|
1999-06-22 07:03:29 +00:00
|
|
|
[])
|
|
|
|
EVT_LISTBOX(self, 401, self.OnSelect)
|
|
|
|
EVT_LISTBOX_DCLICK(self, 401, self.OnDClick)
|
|
|
|
|
1999-09-30 07:11:20 +00:00
|
|
|
self.btn = wxButton(self, 402, "Try it!", wxDLG_PNT(self, 120, 10)).SetDefault()
|
1999-06-22 07:03:29 +00:00
|
|
|
EVT_BUTTON(self, 402, self.OnDClick)
|
|
|
|
|
|
|
|
self.text = wxTextCtrl(self, -1, "",
|
1999-09-30 07:11:20 +00:00
|
|
|
wxDLG_PNT(self, 10, 115),
|
|
|
|
wxDLG_SZE(self, 200, 50),
|
1999-06-22 07:03:29 +00:00
|
|
|
wxTE_MULTILINE | wxTE_READONLY)
|
|
|
|
|
|
|
|
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)
|
|
|
|
win.CentreOnParent(wxBOTH)
|
|
|
|
win.Show(true)
|
|
|
|
win.MakeModal(true)
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
|
|
|
win = TestSelectionPanel(nb, frame)
|
|
|
|
return win
|
|
|
|
|
1999-09-30 07:11:20 +00:00
|
|
|
overview = ""
|
|
|
|
#wxSizer.__doc__ + '\n' + '-' * 80 + '\n' + \
|
|
|
|
#wxBoxSizer.__doc__ + '\n' + '-' * 80 + '\n' + \
|
|
|
|
#wxBorderSizer.__doc__
|
1999-06-22 07:03:29 +00:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
|
|
class MainFrame(wxFrame):
|
|
|
|
def __init__(self):
|
2001-05-18 21:59:59 +00:00
|
|
|
wxFrame.__init__(self, None, -1, "Testing...")
|
1999-06-22 07:03:29 +00:00
|
|
|
|
|
|
|
self.CreateStatusBar()
|
|
|
|
mainmenu = wxMenuBar()
|
|
|
|
menu = wxMenu()
|
|
|
|
menu.Append(200, 'E&xit', 'Get the heck outta here!')
|
|
|
|
mainmenu.Append(menu, "&File")
|
|
|
|
self.SetMenuBar(mainmenu)
|
|
|
|
EVT_MENU(self, 200, self.OnExit)
|
1999-09-30 07:11:20 +00:00
|
|
|
self.panel = TestSelectionPanel(self, self)
|
1999-06-22 07:03:29 +00:00
|
|
|
self.SetSize(wxSize(400, 380))
|
2000-07-15 19:51:35 +00:00
|
|
|
EVT_CLOSE(self, self.OnCloseWindow)
|
1999-06-22 07:03:29 +00:00
|
|
|
|
|
|
|
def OnCloseWindow(self, event):
|
|
|
|
self.Destroy()
|
|
|
|
|
|
|
|
def OnExit(self, event):
|
|
|
|
self.Close(true)
|
|
|
|
|
|
|
|
|
|
|
|
class TestApp(wxApp):
|
|
|
|
def OnInit(self):
|
|
|
|
frame = MainFrame()
|
|
|
|
frame.Show(true)
|
|
|
|
self.SetTopWindow(frame)
|
|
|
|
return true
|
|
|
|
|
|
|
|
app = TestApp(0)
|
|
|
|
app.MainLoop()
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|