Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 02ae703470b471a8282f3c89b4cfdb7f91d21d23 2 parents 1127ad1 + d43e0d5
@rkern rkern authored
Showing with 13 additions and 0 deletions.
  1. +13 −0 pyface/ui/qt4/action/action_item.py
View
13 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. """
Please sign in to comment.
Something went wrong with that request. Please try again.