Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error: 'InstanceFactoryChoice' object has no attribute 'object' #1989

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions traitsui/qt4/instance_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from traitsui.ui_traits import AView
from traitsui.helper import user_name_for
from traitsui.handler import Handler
from traitsui.instance_choice import InstanceChoiceItem
from traitsui.instance_choice import InstanceChoice, InstanceChoiceItem
from .editor import Editor
from .drop_editor import _DropEventFilter
from .constants import DropColor
Expand Down Expand Up @@ -182,11 +182,12 @@ def _get_items(self):
value = adapter(object=value)
# rebuild_items when an item's name changes so it is reflected by
# combobox. This change was added to fix enthought/traitsui#1641
value.object.observe(
self.rebuild_items,
trait(value.name_trait, optional=True),
dispatch="ui",
)
if isinstance(value, InstanceChoice):
value.object.observe(
self.rebuild_items,
trait(value.name_trait, optional=True),
dispatch="ui",
)
items.append(value)

self._items = items
Expand Down