dabo Commit
Revision 4027
Date: 2008-04-04 05:30:03 -0700 (Fri, 04 Apr 2008)
Author: Paul
Trac: http://svn.dabodev.com/trac/dabo/changeset/4027
Changed:
U trunk/dabo/ui/uiwx/dDialog.py
U trunk/dabo/ui/uiwx/dSizerMixin.py
Log:
Made it possible for appdev code to place the ok/cancel buttons in
dOkCancelDialog. Only if they aren't placed in addControls() will
the default placing happen.
Changed the name of the LastPositionInSizer property to
ButtonSizerPosition, to reflect its purpose. Added property
ButtonSizer, for convenience of appdev code.
Fixed dSizer.getPositionInSizer() to return None if there isn't
any containing sizer - it appears this was the intent all along.
Diff:
Modified: trunk/dabo/ui/uiwx/dDialog.py
===================================================================
--- trunk/dabo/ui/uiwx/dDialog.py 2008-04-03 23:58:02 UTC (rev 4026)
+++ trunk/dabo/ui/uiwx/dDialog.py 2008-04-04 12:30:03 UTC (rev 4027)
@@ -232,18 +232,17 @@
self.btnCancel = dabo.ui.dButton(self, id=wx.ID_CANCEL,
CancelButton=True)
self.btnCancel.bindEvent(dEvents.Hit, self.onCancel)
- # Let the user add their controls
- super(dOkCancelDialog, self)._addControls()
-
- # Just in case user changed Self.Sizer, update our reference:
- sz = self.Sizer
-
# Put the buttons in a StdDialogButtonSizer, so they get
positioned/sized
- # per the native platform conventions, and add that sizer to
self.Sizer:
+ # per the native platform conventions:
buttonSizer = wx.StdDialogButtonSizer()
buttonSizer.AddButton(self.btnOK)
buttonSizer.AddButton(self.btnCancel)
buttonSizer.Realize()
+
+ self._btnSizer = bs = dabo.ui.dSizer("v")
+ bs.append((0, sz.DefaultBorder/2))
+ bs.append(buttonSizer, "x")
+ bs.append((0, sz.DefaultBorder))
# Wx rearranges the order of the buttons per platform
conventions, but
# doesn't rearrange the tab order for us. So, we do it manually:
@@ -254,11 +253,15 @@
buttons.append(win)
buttons[1].MoveAfterInTabOrder(buttons[0])
- self.btnSizer = bs = dabo.ui.dSizer("v")
- bs.append((0, sz.DefaultBorder/2))
- bs.append(buttonSizer, "x")
- bs.append((0, sz.DefaultBorder))
- sz.append(bs, "x")
+ # Let the user add their controls
+ super(dOkCancelDialog, self)._addControls()
+
+ # Just in case user changed Self.Sizer, update our reference:
+ sz = self.Sizer
+
+ if self.ButtonSizerPosition is None:
+ # User code didn't add it, so we must.
+ sz.append(bs, "x")
self.layout()
@@ -329,29 +332,35 @@
self._accepted = val
+ def _getButtonSizer(self):
+ return getattr(self, "_btnSizer", None)
+
+
+ def _getButtonSizerPosition(self):
+ return self.ButtonSizer.getPositionInSizer()
+
+
def _getCancelButton(self):
return self.btnCancel
-
- def _getLastPositionInSizer(self):
- return self.btnSizer.getPositionInSizer()
-
def _getOKButton(self):
return self.btnOK
Accepted = property(_getAccepted, _setAccepted, None,
_("Specifies whether the user accepted the dialog, or
canceled. (bool)"))
-
+
+ ButtonSizer = property(_getButtonSizer, None, None,
+ _("Returns a reference to the sizer controlling the
Ok/Cancel buttons. (dSizer)"))
+
+ ButtonSizerPosition = property(_getButtonSizerPosition, None, None,
+ _("""Returns the position of the Ok/Cancel buttons in
the sizer. (int)"""))
+
CancelButton = property(_getCancelButton, None, None,
_("Reference to the Cancel button on the form
(dButton)."))
- LastPositionInSizer = property(_getLastPositionInSizer, None, None,
- _("""If you want to add controls after the dialog has
been created,
- use this as the argument to the sizer.insert() call. It
returns
- the position in the sizer before the OK/Cancel buttons
and the
- preceeding spacer. (int)"""))
+ LastPositionInSizer = ButtonSizerPosition ## backwards compatibility
OKButton = property(_getOKButton, None, None,
_("Reference to the OK button on the form (dButton)."))
Modified: trunk/dabo/ui/uiwx/dSizerMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dSizerMixin.py 2008-04-03 23:58:02 UTC (rev 4026)
+++ trunk/dabo/ui/uiwx/dSizerMixin.py 2008-04-04 12:30:03 UTC (rev 4027)
@@ -262,8 +262,9 @@
def getPositionInSizer(self):
- """ Returns the current position of this sizer in its
containing sizer."""
- sz = self._controllingSizer
+ """Returns the current position of this sizer in its containing
sizer, or None
+ if there isn't a containing sizer."""
+ sz = getattr(self, "_controllingSizer", None)
if not sz:
return None
if isinstance(sz, wx.BoxSizer):
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]