dabo Commit
Revision 6396
Date: 2011-02-06 09:14:26 -0800 (Sun, 06 Feb 2011)
Author: Ed
Trac: http://trac.dabodev.com/changeset/6396
Changed:
U trunk/dabo/ui/uiwx/dToolBar.py
Log:
Added the ToolbarItemClass property, allowing you to define your own subclasses
for a toolbar's items. The default remains dToolBarItem.
Diff:
Modified: trunk/dabo/ui/uiwx/dToolBar.py
===================================================================
--- trunk/dabo/ui/uiwx/dToolBar.py 2011-02-06 16:59:27 UTC (rev 6395)
+++ trunk/dabo/ui/uiwx/dToolBar.py 2011-02-06 17:14:26 UTC (rev 6396)
@@ -25,6 +25,7 @@
"""
def __init__(self, parent, properties=None, attProperties=None, *args,
**kwargs):
self._baseClass = dToolBar
+ self._toolbarItemClass = dToolBarItem
preClass = wx.PreToolBar
style = self._extractKey((kwargs, properties, attProperties),
"style", 0)
@@ -172,7 +173,8 @@
# insert
tool = self.InsertTool(pos, id_, caption, picBmp,
shortHelpString=tip, longHelpString=help,
isToggle=toggle)
- butt = dToolBarItem(tool, *args, **kwargs)
+ tbiClass = self.ToolbarItemClass
+ butt = tbiClass(tool, *args, **kwargs)
try:
self.SetToggle(id_, toggle)
@@ -224,7 +226,8 @@
def appendSeparator(self):
"""Inserts a separator at the end of the toolbar."""
- sep = dToolBarItem(self.AddSeparator())
+ tbiClass = self.ToolbarItemClass
+ sep = tbiClass(self.AddSeparator())
self._daboChildren.append(sep)
sep._parent = self
self._realize()
@@ -233,7 +236,8 @@
def insertSeparator(self, pos):
"""Inserts a separator before the specified position in the
toolbar."""
- sep = dToolBarItem(self.InsertSeparator(pos))
+ tbiClass = self.ToolbarItemClass
+ sep = tbiClass(self.InsertSeparator(pos))
self._daboChildren.insert(pos, sep)
sep._parent = self
self._realize()
@@ -410,6 +414,16 @@
self._properties["ShowIcons"] = val
+ def _getToolbarItemClass(self):
+ return self._toolbarItemClass
+
+ def _setToolbarItemClass(self, val):
+ if self._constructed():
+ self._toolbarItemClass = val
+ else:
+ self._properties["ToolbarItemClass"] = val
+
+
Dockable = property(_getDockable, _setDockable, None,
_("""Specifies whether the toolbar can be docked and undocked.
(bool)
@@ -437,7 +451,10 @@
Note that you can set both ShowCaptions and ShowIcons to False,
but in
that case, the icons will still show. Default is True."""))
+ ToolbarItemClass = property(_getToolbarItemClass, _setToolbarItemClass,
None,
+ _("""Class to instantiate for toolbar items.
Default=dToolBarItem. (varies)"""))
+
DynamicShowCaptions = makeDynamicProperty(ShowCaptions)
DynamicShowIcons = makeDynamicProperty(ShowIcons)
@@ -599,6 +616,7 @@
else:
dabo.ui.stop("Sorry, there isn't an app object - can't
exit.")
+
if __name__ == "__main__":
import test
test.Test().runTest(_dToolBar_test)
_______________________________________________
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]