Permalink
Browse files

Merge pull request #90 from pankajp/toolbar-action-listen-name-change

ToolBar: Listen to Action name changes for toolbar actions.
  • Loading branch information...
2 parents 1127ad1 + d43e0d5 commit 02ae703470b471a8282f3c89b4cfdb7f91d21d23 @rkern rkern committed Feb 21, 2014
Showing with 13 additions and 0 deletions.
  1. +13 −0 pyface/ui/qt4/action/action_item.py
@@ -300,6 +300,9 @@ def __init__(self, parent, tool_bar, image_cache, item, controller,
action.on_trait_change(self._on_action_enabled_changed, 'enabled')
action.on_trait_change(self._on_action_visible_changed, 'visible')
action.on_trait_change(self._on_action_checked_changed, 'checked')
+ action.on_trait_change(self._on_action_name_changed, 'name')
+ action.on_trait_change(self._on_action_accelerator_changed,
+ 'accelerator')
# Detect if the control is destroyed.
self.control.destroyed.connect(self._qt4_on_destroyed)
@@ -389,6 +392,16 @@ def _on_action_checked_changed(self, action, trait_name, old, new):
if self.control is not None:
self.control.setChecked(action.checked)
+ def _on_action_name_changed(self, action, trait_name, old, new):
+ """ Called when the name trait is changed on an action. """
+ if self.control is not None:
+ self.control.setText(action.name)
+
+ def _on_action_accelerator_changed(self, action, trait_name, old, new):
+ """ Called when the accelerator trait is changed on an action. """
+ if self.control is not None:
+ self.control.setShortcut(action.accelerator)
+
class _PaletteTool(HasTraits):
""" A tool palette representation of an action item. """

0 comments on commit 02ae703

Please sign in to comment.