From b64274c77a190cd44daaf15e0f96c0e3ee864113 Mon Sep 17 00:00:00 2001 From: Kevin Ollivier Date: Sat, 6 Jan 2007 02:09:00 +0000 Subject: [PATCH] Add a grid sizer demo, and document the props accepted by SetSizerProps. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44102 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/demo/SizedControls.py | 93 ++++++++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 4 deletions(-) diff --git a/wxPython/demo/SizedControls.py b/wxPython/demo/SizedControls.py index 925e717826..63b237a3e7 100644 --- a/wxPython/demo/SizedControls.py +++ b/wxPython/demo/SizedControls.py @@ -74,10 +74,56 @@ b3 = wx.Button(panel, -1) and the latter example will adhere to HIG spacing guidelines on all platforms, -unlike the former example. - -Please check the demos for more complete and sophisticated examples of SizedControls +unlike the former example. Please check the demos for more complete and sophisticated examples of SizedControls in action. + +

wx.Window.SetSizerProps Quick Reference

+ +

wx.Window.SetSizerProps(<props>)
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Parameter Values Summary
expand True/FalseWhether or not the control should grow to fill free space if +free space is available.
proportion Number (typically 0-10)How much of the free space the control should take up. Note that this value is +relative to other controls, so a proportion of 2 means take up +'twice as much' space as controls with a proportion of 1.
halign "left", "center", "centre", "right"Determines horizontal alignment of control.
valign "top", "center", "centre", "bottom"Determines vertical alignment of control.
border Tuple: ([dirs], integer)Specifies amount of border padding to apply to specified directions.
+Example: (["left", "right"], 6) would add six pixels to left and right borders.
+Note that, unfortunately, +it is not currently possible to assign different border sizes to each direction.
minsize One of the following string values: "fixed", "adjust"Determines whether or not the minsize can be updated when the control's best size changes.
""" class FormDialog(sc.SizedDialog): @@ -176,6 +222,35 @@ class ErrorDialog(sc.SizedDialog): self.listCtrl.SetColumnWidth(0, 100) self.listCtrl.SetColumnWidth(1, 280) + +class GridFrame(sc.SizedFrame): + def __init__(self, parent, id): + sc.SizedFrame.__init__(self, parent, id, "Grid Layout Demo Frame") + + pane = self.GetContentsPane() + pane.SetSizerType("grid", {"cols":3}) # 3-column grid layout + + # row 1 + wx.TextCtrl(pane, -1).SetSizerProps(halign="left") + wx.TextCtrl(pane, -1).SetSizerProps(halign="center") + wx.TextCtrl(pane, -1).SetSizerProps(halign="right") + + # row 2 + wx.TextCtrl(pane, -1).SetSizerProps(valign="center") + wx.TextCtrl(pane, -1).SetSizerProps(expand=True, proportion=1) + wx.TextCtrl(pane, -1).SetSizerProps(valign="center") + + # row 3 + wx.TextCtrl(pane, -1).SetSizerProps(halign="left") + wx.TextCtrl(pane, -1).SetSizerProps(halign="center") + wx.TextCtrl(pane, -1).SetSizerProps(halign="right") + + self.CreateStatusBar() # should always do this when there's a resize border + + self.Fit() + self.SetMinSize(self.GetSize()) + + #--------------------------------------------------------------------------- class TestPanel(wx.Panel): @@ -188,7 +263,10 @@ class TestPanel(wx.Panel): self.Bind(wx.EVT_BUTTON, self.OnFormButton, b) b2 = wx.Button(self, -1, "Sized Controls Error Dialog", (50,90)) - self.Bind(wx.EVT_BUTTON, self.OnErrorButton, b2) + self.Bind(wx.EVT_BUTTON, self.OnErrorButton, b2) + + b3 = wx.Button(self, -1, "Sized Controls Grid Layout Demo", (50,130)) + self.Bind(wx.EVT_BUTTON, self.OnGridButton, b3) def OnFormButton(self, evt): @@ -221,6 +299,13 @@ class TestPanel(wx.Panel): dlg.Destroy() + def OnGridButton(self, evt): + + dlg = GridFrame(self, -1) + dlg.CenterOnScreen() + + dlg.Show() + def runTest(frame, nb, log): win = TestPanel(nb, log) return win -- 2.45.2