dabo Commit
Revision 7043
Date: 2012-01-01 08:24:02 -0800 (Sun, 01 Jan 2012)
Author: Ed
Trac: http://trac.dabodev.com/changeset/7043
Changed:
U trunk/dabo/ui/uiwx/__init__.py
U trunk/dabo/ui/uiwx/dPemMixin.py
Log:
Added several methods for simplifying interacting with a control's
ControllingSizer. This is an intermediate step; next these will be refactored
into the sizer classes themselves.
Diff:
Modified: trunk/dabo/ui/uiwx/__init__.py
===================================================================
--- trunk/dabo/ui/uiwx/__init__.py 2011-12-28 22:33:01 UTC (rev 7042)
+++ trunk/dabo/ui/uiwx/__init__.py 2012-01-01 16:24:02 UTC (rev 7043)
@@ -1666,7 +1666,28 @@
return None
+def setPositionInSizer(obj, pos):
+ sz = obj.GetContainingSizer()
+ if not sz:
+ return None
+ orig_pos = getPositionInSizer(obj)
+ # Copy the current sizer props
+ props = obj.getSizerProps()
+ if isinstance(sz, wx.BoxSizer):
+ sz.remove(obj)
+ sz.insert(pos, obj)
+ sz.setItemProps(obj, props)
+ elif isinstance(sz, wx.GridBagSizer):
+ row, col = pos
+ print sz.getItemByRowCol(row, col)
+ if sz.getItemByRowCol(row, col):
+ raise ValueError(_("An object already exists at %s,
%s") % (row, col))
+ sz.remove(obj)
+ sz.append(obj)
+ sz.setItemProps(obj, props)
+ sz.layout()
+
def fontMetricFromFont(txt, font):
if isinstance(font, dabo.ui.dFont):
font = font._nativeFont
Modified: trunk/dabo/ui/uiwx/dPemMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dPemMixin.py 2011-12-28 22:33:01 UTC (rev 7042)
+++ trunk/dabo/ui/uiwx/dPemMixin.py 2012-01-01 16:24:02 UTC (rev 7043)
@@ -847,12 +847,35 @@
return ret
+ def getSizerProps(self):
+ """
+ Returns a dict containing the object's sizer property info. The
+ keys are the property names, and the values are the current
+ values for those props.
+ """
+ ret = None
+ if self.ControllingSizer:
+ ret = self.ControllingSizer.getItemProps(self)
+ return ret
+
+
def setSizerProp(self, prop, val):
"""Tells the object's ControllingSizer to adjust the requested
property."""
if self.ControllingSizer:
self.ControllingSizer.setItemProp(self, prop, val)
+ def setSizerProps(self, propDict):
+ """
+ Convenience method for setting multiple sizer item properties
at once. The
+ dict should have the property name as the key and the desired
new value
+ as the associated value.
+ """
+ if self.ControllingSizer:
+ for prop, val in propDict.iteritems():
+ self.ControllingSizer.setItemProp(self, prop,
val)
+
+
def moveTabOrderBefore(self, obj):
"""Moves this object's tab order before the passed obj."""
self.MoveBeforeInTabOrder(obj)
@@ -1185,6 +1208,11 @@
return dabo.ui.getPositionInSizer(self)
+ def setPositionInSizer(self, pos):
+ """Convenience method to let you call this directly on the
object."""
+ return dabo.ui.setPositionInSizer(self, pos)
+
+
def setAll(self, prop, val, recurse=True, filt=None, instancesOf=None):
"""
Set all child object properties to the passed value.
_______________________________________________
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]