1. wxHtmlHelpController and related classes
2. the C++ versions of wxSizer and firends, Python versions are 'depreciated' 3. wxPyEvent and wxPyCommandEvent, event classes that can carry some python objects through the event system and safely come back out again. 4. wxGridSizer and wxFlexGridSizer 5. wxValidator 6. wxPyOnDemandOutputWindow 7. several tweaks, fixes and additions of missing methods, etc. 8. and probably several other things I am forgetting since CVS was down so long... git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3758 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -2,17 +2,17 @@
|
||||
# sizer test code
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.lib.sizers import *
|
||||
from wxPython.wx import *
|
||||
from wxPython.lib.grids import wxGridSizer, wxFlexGridSizer
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBox1(win):
|
||||
box = wxBoxSizer(wxHORIZONTAL)
|
||||
box.Add(wxButton(win, 1010, "one"), 0)
|
||||
box.Add(wxButton(win, 1010, "two"), 0)
|
||||
box.Add(wxButton(win, 1010, "three"), 0)
|
||||
box.Add(wxButton(win, 1010, "four"), 0)
|
||||
box.Add(wxButton(win, 1010, "one"), 0, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "two"), 0, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "three"), 0, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "four"), 0, wxGROW)
|
||||
|
||||
return box
|
||||
|
||||
@@ -20,10 +20,10 @@ def makeSimpleBox1(win):
|
||||
|
||||
def makeSimpleBox2(win):
|
||||
box = wxBoxSizer(wxVERTICAL)
|
||||
box.Add(wxButton(win, 1010, "one"), 0)
|
||||
box.Add(wxButton(win, 1010, "two"), 0)
|
||||
box.Add(wxButton(win, 1010, "three"), 0)
|
||||
box.Add(wxButton(win, 1010, "four"), 0)
|
||||
box.Add(wxButton(win, 1010, "one"), 0, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "two"), 0, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "three"), 0, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "four"), 0, wxGROW)
|
||||
|
||||
return box
|
||||
|
||||
@@ -31,11 +31,11 @@ def makeSimpleBox2(win):
|
||||
|
||||
def makeSimpleBox3(win):
|
||||
box = wxBoxSizer(wxHORIZONTAL)
|
||||
box.Add(wxButton(win, 1010, "one"), 0)
|
||||
box.Add(wxButton(win, 1010, "two"), 0)
|
||||
box.Add(wxButton(win, 1010, "three"), 0)
|
||||
box.Add(wxButton(win, 1010, "four"), 0)
|
||||
box.Add(wxButton(win, 1010, "five"), 1)
|
||||
box.Add(wxButton(win, 1010, "one"), 0, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "two"), 0, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "three"), 0, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "four"), 0, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "five"), 1, wxGROW)
|
||||
|
||||
return box
|
||||
|
||||
@@ -43,11 +43,11 @@ def makeSimpleBox3(win):
|
||||
|
||||
def makeSimpleBox4(win):
|
||||
box = wxBoxSizer(wxHORIZONTAL)
|
||||
box.Add(wxButton(win, 1010, "one"), 0)
|
||||
box.Add(wxButton(win, 1010, "two"), 0)
|
||||
box.Add(wxButton(win, 1010, "three"), 1)
|
||||
box.Add(wxButton(win, 1010, "four"), 1)
|
||||
box.Add(wxButton(win, 1010, "five"), 1)
|
||||
box.Add(wxButton(win, 1010, "one"), 0, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "two"), 0, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "three"), 1, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "four"), 1, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "five"), 1, wxGROW)
|
||||
|
||||
return box
|
||||
|
||||
@@ -55,53 +55,66 @@ def makeSimpleBox4(win):
|
||||
|
||||
def makeSimpleBox5(win):
|
||||
box = wxBoxSizer(wxHORIZONTAL)
|
||||
box.Add(wxButton(win, 1010, "one"), 0)
|
||||
box.Add(wxButton(win, 1010, "two"), 0)
|
||||
box.Add(wxButton(win, 1010, "three"), 3)
|
||||
box.Add(wxButton(win, 1010, "four"), 1)
|
||||
box.Add(wxButton(win, 1010, "five"), 1)
|
||||
box.Add(wxButton(win, 1010, "one"), 0, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "two"), 0, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "three"), 3, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "four"), 1, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "five"), 1, wxGROW)
|
||||
|
||||
return box
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBox6(win):
|
||||
box = wxBoxSizer(wxHORIZONTAL, wxSize(250, 50))
|
||||
box.Add(wxButton(win, 1010, "10"), 10)
|
||||
box.Add(wxButton(win, 1010, "20"), 20)
|
||||
box.Add(wxButton(win, 1010, "30"), 30)
|
||||
box.Add(wxButton(win, 1010, "15"), 15)
|
||||
box.Add(wxButton(win, 1010, "5"), 5)
|
||||
box = wxBoxSizer(wxHORIZONTAL)
|
||||
box.Add(wxButton(win, 1010, "one"), 1, wxALIGN_TOP)
|
||||
box.Add(wxButton(win, 1010, "two"), 1, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "three"), 1, wxCENTER)
|
||||
box.Add(wxButton(win, 1010, "four"), 1, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "five"), 1, wxALIGN_BOTTOM)
|
||||
|
||||
return box
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBox7(win):
|
||||
box = wxBoxSizer(wxHORIZONTAL)
|
||||
box.Add(wxButton(win, 1010, "one"), 0, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "two"), 0, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "three"), 0, wxGROW)
|
||||
box.Add(60, 20, 0, wxGROW)
|
||||
box.Add(wxButton(win, 1010, "five"), 1, wxGROW)
|
||||
|
||||
return box
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBorder1(win):
|
||||
bdr = wxBorderSizer(wxALL)
|
||||
bdr = wxBoxSizer(wxHORIZONTAL)
|
||||
btn = wxButton(win, 1010, "border")
|
||||
btn.SetSize(wxSize(80, 80))
|
||||
bdr.Add(btn, 15)
|
||||
bdr.Add(btn, 1, wxGROW|wxALL, 15)
|
||||
|
||||
return bdr
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBorder2(win):
|
||||
bdr = wxBorderSizer(wxEAST | wxWEST)
|
||||
bdr = wxBoxSizer(wxHORIZONTAL)
|
||||
btn = wxButton(win, 1010, "border")
|
||||
btn.SetSize(wxSize(80, 80))
|
||||
bdr.Add(btn, 15)
|
||||
bdr.Add(btn, 1, wxGROW | wxEAST | wxWEST, 15)
|
||||
|
||||
return bdr
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBorder3(win):
|
||||
bdr = wxBorderSizer(wxNORTH | wxWEST)
|
||||
bdr = wxBoxSizer(wxHORIZONTAL)
|
||||
btn = wxButton(win, 1010, "border")
|
||||
btn.SetSize(wxSize(80, 80))
|
||||
bdr.Add(btn, 15)
|
||||
bdr.Add(btn, 1, wxGROW | wxNORTH | wxWEST, 15)
|
||||
|
||||
return bdr
|
||||
|
||||
@@ -111,35 +124,35 @@ def makeSimpleBorder3(win):
|
||||
def makeBoxInBox(win):
|
||||
box = wxBoxSizer(wxVERTICAL)
|
||||
|
||||
box.Add(wxButton(win, 1010, "one"))
|
||||
box.Add(wxButton(win, 1010, "one"), 0, wxGROW)
|
||||
|
||||
box2 = wxBoxSizer(wxHORIZONTAL)
|
||||
box2.AddMany([ wxButton(win, 1010, "two"),
|
||||
wxButton(win, 1010, "three"),
|
||||
wxButton(win, 1010, "four"),
|
||||
wxButton(win, 1010, "five"),
|
||||
box2.AddMany([ (wxButton(win, 1010, "two"), 0, wxGROW),
|
||||
(wxButton(win, 1010, "three"), 0, wxGROW),
|
||||
(wxButton(win, 1010, "four"), 0, wxGROW),
|
||||
(wxButton(win, 1010, "five"), 0, wxGROW),
|
||||
])
|
||||
|
||||
box3 = wxBoxSizer(wxVERTICAL)
|
||||
box3.AddMany([ (wxButton(win, 1010, "six"), 0),
|
||||
(wxButton(win, 1010, "seven"), 2),
|
||||
(wxButton(win, 1010, "eight"), 1),
|
||||
(wxButton(win, 1010, "nine"), 1),
|
||||
box3.AddMany([ (wxButton(win, 1010, "six"), 0, wxGROW),
|
||||
(wxButton(win, 1010, "seven"), 2, wxGROW),
|
||||
(wxButton(win, 1010, "eight"), 1, wxGROW),
|
||||
(wxButton(win, 1010, "nine"), 1, wxGROW),
|
||||
])
|
||||
|
||||
box2.Add(box3, 1)
|
||||
box.Add(box2, 1)
|
||||
box2.Add(box3, 1, wxGROW)
|
||||
box.Add(box2, 1, wxGROW)
|
||||
|
||||
box.Add(wxButton(win, 1010, "ten"))
|
||||
box.Add(wxButton(win, 1010, "ten"), 0, wxGROW)
|
||||
|
||||
return box
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeBoxInBorder(win):
|
||||
bdr = wxBorderSizer(wxALL)
|
||||
bdr = wxBoxSizer(wxHORIZONTAL)
|
||||
box = makeSimpleBox3(win)
|
||||
bdr.Add(box, 15)
|
||||
bdr.Add(box, 1, wxGROW | wxALL, 15)
|
||||
|
||||
return bdr
|
||||
|
||||
@@ -149,37 +162,106 @@ def makeBorderInBox(win):
|
||||
insideBox = wxBoxSizer(wxHORIZONTAL)
|
||||
|
||||
box2 = wxBoxSizer(wxHORIZONTAL)
|
||||
box2.AddMany([ wxButton(win, 1010, "one"),
|
||||
wxButton(win, 1010, "two"),
|
||||
wxButton(win, 1010, "three"),
|
||||
wxButton(win, 1010, "four"),
|
||||
wxButton(win, 1010, "five"),
|
||||
box2.AddMany([ (wxButton(win, 1010, "one"), 0, wxGROW),
|
||||
(wxButton(win, 1010, "two"), 0, wxGROW),
|
||||
(wxButton(win, 1010, "three"), 0, wxGROW),
|
||||
(wxButton(win, 1010, "four"), 0, wxGROW),
|
||||
(wxButton(win, 1010, "five"), 0, wxGROW),
|
||||
])
|
||||
|
||||
insideBox.Add(box2, 0)
|
||||
insideBox.Add(box2, 0, wxGROW)
|
||||
|
||||
bdr = wxBorderSizer(wxALL)
|
||||
bdr.Add(wxButton(win, 1010, "border"), 20)
|
||||
insideBox.Add(bdr, 1)
|
||||
bdr = wxBoxSizer(wxHORIZONTAL)
|
||||
bdr.Add(wxButton(win, 1010, "border"), 1, wxGROW | wxALL)
|
||||
insideBox.Add(bdr, 1, wxGROW | wxALL, 20)
|
||||
|
||||
box3 = wxBoxSizer(wxVERTICAL)
|
||||
box3.AddMany([ (wxButton(win, 1010, "six"), 0),
|
||||
(wxButton(win, 1010, "seven"), 2),
|
||||
(wxButton(win, 1010, "eight"), 1),
|
||||
(wxButton(win, 1010, "nine"), 1),
|
||||
box3.AddMany([ (wxButton(win, 1010, "six"), 0, wxGROW),
|
||||
(wxButton(win, 1010, "seven"), 2, wxGROW),
|
||||
(wxButton(win, 1010, "eight"), 1, wxGROW),
|
||||
(wxButton(win, 1010, "nine"), 1, wxGROW),
|
||||
])
|
||||
insideBox.Add(box3, 1)
|
||||
insideBox.Add(box3, 1, wxGROW)
|
||||
|
||||
outsideBox = wxBoxSizer(wxVERTICAL)
|
||||
outsideBox.Add(wxButton(win, 1010, "top"))
|
||||
outsideBox.Add(insideBox, 1)
|
||||
outsideBox.Add(wxButton(win, 1010, "bottom"))
|
||||
outsideBox.Add(wxButton(win, 1010, "top"), 0, wxGROW)
|
||||
outsideBox.Add(insideBox, 1, wxGROW)
|
||||
outsideBox.Add(wxButton(win, 1010, "bottom"), 0, wxGROW)
|
||||
|
||||
return outsideBox
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeGrid1(win):
|
||||
gs = wxGridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
|
||||
|
||||
gs.AddMany([ (wxButton(win, 1010, 'one'), 0, wxGROW),
|
||||
(wxButton(win, 1010, 'two'), 0, wxGROW),
|
||||
(wxButton(win, 1010, 'three'), 0, wxGROW),
|
||||
(wxButton(win, 1010, 'four'), 0, wxGROW),
|
||||
(wxButton(win, 1010, 'five'), 0, wxGROW),
|
||||
#(75, 50),
|
||||
(wxButton(win, 1010, 'six'), 0, wxGROW),
|
||||
(wxButton(win, 1010, 'seven'), 0, wxGROW),
|
||||
(wxButton(win, 1010, 'eight'), 0, wxGROW),
|
||||
(wxButton(win, 1010, 'nine'), 0, wxGROW),
|
||||
])
|
||||
|
||||
return gs
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeGrid2(win):
|
||||
gs = wxGridSizer(3, 3) # rows, cols, hgap, vgap
|
||||
|
||||
box = wxBoxSizer(wxVERTICAL)
|
||||
box.Add(wxButton(win, 1010, 'A'), 0, wxGROW)
|
||||
box.Add(wxButton(win, 1010, 'B'), 1, wxGROW)
|
||||
|
||||
gs2 = wxGridSizer(2,2, 4, 4)
|
||||
gs2.AddMany([ (wxButton(win, 1010, 'C'), 0, wxGROW),
|
||||
(wxButton(win, 1010, 'E'), 0, wxGROW),
|
||||
(wxButton(win, 1010, 'F'), 0, wxGROW),
|
||||
(wxButton(win, 1010, 'G'), 0, wxGROW)])
|
||||
|
||||
gs.AddMany([ (wxButton(win, 1010, 'one'), 0, wxALIGN_RIGHT | wxALIGN_BOTTOM),
|
||||
(wxButton(win, 1010, 'two'), 0, wxGROW),
|
||||
(wxButton(win, 1010, 'three'), 0, wxALIGN_LEFT | wxALIGN_BOTTOM),
|
||||
(wxButton(win, 1010, 'four'), 0, wxGROW),
|
||||
(wxButton(win, 1010, 'five'), 0, wxCENTER),
|
||||
(wxButton(win, 1010, 'six'), 0, wxGROW),
|
||||
(box, 0, wxGROW | wxALL, 10),
|
||||
(wxButton(win, 1010, 'eight'), 0, wxGROW),
|
||||
(gs2, 0, wxGROW | wxALL, 4),
|
||||
])
|
||||
|
||||
return gs
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeGrid3(win):
|
||||
gs = wxFlexGridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
|
||||
|
||||
gs.AddMany([ (wxButton(win, 1010, 'one'), 0, wxGROW),
|
||||
(wxButton(win, 1010, 'two'), 0, wxGROW),
|
||||
(wxButton(win, 1010, 'three'), 0, wxGROW),
|
||||
(wxButton(win, 1010, 'four'), 0, wxGROW),
|
||||
#(wxButton(win, 1010, 'five'), 0, wxGROW),
|
||||
(175, 50),
|
||||
(wxButton(win, 1010, 'six'), 0, wxGROW),
|
||||
(wxButton(win, 1010, 'seven'), 0, wxGROW),
|
||||
(wxButton(win, 1010, 'eight'), 0, wxGROW),
|
||||
(wxButton(win, 1010, 'nine'), 0, wxGROW),
|
||||
])
|
||||
|
||||
gs.AddGrowableRow(0)
|
||||
gs.AddGrowableRow(2)
|
||||
gs.AddGrowableCol(1)
|
||||
return gs
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
theTests = [
|
||||
("Simple horizontal boxes", makeSimpleBox1,
|
||||
"This is a HORIZONTAL box sizer with four non-stretchable buttons held "
|
||||
@@ -208,6 +290,17 @@ theTests = [
|
||||
"factor so it gets more of the free space."
|
||||
),
|
||||
|
||||
("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."
|
||||
),
|
||||
|
||||
# ("Percent Sizer", makeSimpleBox6,
|
||||
# "You can use the wxBoxSizer like a Percent Sizer. Just make sure that all "
|
||||
# "the weighting factors add up to 100!"
|
||||
@@ -245,6 +338,29 @@ theTests = [
|
||||
"Another nesting example. This one has Boxes and a Border inside another Box."
|
||||
),
|
||||
|
||||
("", 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."
|
||||
),
|
||||
|
||||
]
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
@@ -256,12 +372,10 @@ class TestFrame(wxFrame):
|
||||
self.sizer = sizerFunc(self)
|
||||
self.CreateStatusBar()
|
||||
self.SetStatusText("Resize this frame to see how the sizers respond...")
|
||||
self.sizer.FitWindow(self)
|
||||
self.sizer.Fit(self)
|
||||
|
||||
|
||||
def OnSize(self, event):
|
||||
size = self.GetClientSize()
|
||||
self.sizer.Layout(size)
|
||||
self.SetAutoLayout(true)
|
||||
self.SetSizer(self.sizer)
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.MakeModal(false)
|
||||
@@ -280,17 +394,17 @@ class TestSelectionPanel(wxPanel):
|
||||
self.frame = frame
|
||||
|
||||
self.list = wxListBox(self, 401,
|
||||
wxDLG_PNT(self, 10, 10), wxDLG_SZE(self, 100, 60),
|
||||
wxDLG_PNT(self, 10, 10), wxDLG_SZE(self, 100, 100),
|
||||
[])
|
||||
EVT_LISTBOX(self, 401, self.OnSelect)
|
||||
EVT_LISTBOX_DCLICK(self, 401, self.OnDClick)
|
||||
|
||||
wxButton(self, 402, "Try it!", wxDLG_PNT(self, 120, 10)).SetDefault()
|
||||
self.btn = wxButton(self, 402, "Try it!", wxDLG_PNT(self, 120, 10)).SetDefault()
|
||||
EVT_BUTTON(self, 402, self.OnDClick)
|
||||
|
||||
self.text = wxTextCtrl(self, -1, "",
|
||||
wxDLG_PNT(self, 10, 80),
|
||||
wxDLG_SZE(self, 200, 60),
|
||||
wxDLG_PNT(self, 10, 115),
|
||||
wxDLG_SZE(self, 200, 50),
|
||||
wxTE_MULTILINE | wxTE_READONLY)
|
||||
|
||||
for item in theTests:
|
||||
@@ -320,9 +434,10 @@ def runTest(frame, nb, log):
|
||||
win = TestSelectionPanel(nb, frame)
|
||||
return win
|
||||
|
||||
overview = wxSizer.__doc__ + '\n' + '-' * 80 + '\n' + \
|
||||
wxBoxSizer.__doc__ + '\n' + '-' * 80 + '\n' + \
|
||||
wxBorderSizer.__doc__
|
||||
overview = ""
|
||||
#wxSizer.__doc__ + '\n' + '-' * 80 + '\n' + \
|
||||
#wxBoxSizer.__doc__ + '\n' + '-' * 80 + '\n' + \
|
||||
#wxBorderSizer.__doc__
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
@@ -341,7 +456,7 @@ if __name__ == '__main__':
|
||||
mainmenu.Append(menu, "&File")
|
||||
self.SetMenuBar(mainmenu)
|
||||
EVT_MENU(self, 200, self.OnExit)
|
||||
self.panel = TestSelectionPanel(self)
|
||||
self.panel = TestSelectionPanel(self, self)
|
||||
self.SetSize(wxSize(400, 380))
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
|
Reference in New Issue
Block a user