Skip to content

Commit 91a9220

Browse files
authored
Backports for 7.3.0 (#893)
* don't use trait() for extended trait names (#892) * add cherry-picked PR to changelog
1 parent 65954c8 commit 91a9220

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

CHANGES.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ Build, Tests and Continuous Integration
5050

5151
Maintenance and code reorganization
5252

53-
* Replace use of ``traits`` ``on_trait_change`` with ``observe``. (#882, #881,
54-
#880, #870, #864)
53+
* Replace use of ``traits`` ``on_trait_change`` with ``observe``. (#892, #882,
54+
#881, #880, #870, #864)
5555
* Import from ``traits.api`` where possible. (#866)
5656
* Expose keyboard focus on Widgets. (#862)
5757
* Remove support for PySide. (#861)

pyface/action/listening_action.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,14 @@ def destroy(self):
5656
"""
5757

5858
if self.object:
59-
self.object.observe(
60-
self._enabled_update,
61-
trait(self.enabled_name, optional=True),
62-
remove=True
63-
)
64-
self.object.observe(
65-
self._visible_update,
66-
trait(self.visible_name, optional=True),
67-
remove=True
68-
)
59+
if self.enabled_name:
60+
self.object.observe(
61+
self._enabled_update, self.enabled_name, remove=True
62+
)
63+
if self.visible_name:
64+
self.object.observe(
65+
self._visible_update, self.visible_name, remove=True
66+
)
6967

7068
def perform(self, event=None):
7169
""" Call the appropriate function.
@@ -125,11 +123,12 @@ def _object_changed(self, old, new):
125123
for kind in ("enabled", "visible"):
126124
method = getattr(self, "_%s_update" % kind)
127125
name = getattr(self, "%s_name" % kind)
128-
if old and old is not Undefined:
129-
old.observe(method, trait(name, optional=True), remove=True)
130-
if new:
131-
new.observe(method, trait(name, optional=True))
132-
method()
126+
if name:
127+
if old and old is not Undefined:
128+
old.observe(method, name, remove=True)
129+
if new:
130+
new.observe(method, name)
131+
method()
133132

134133
def _enabled_update(self, event=None):
135134
if self.enabled_name:

0 commit comments

Comments
 (0)