Skip to content

Commit

Permalink
fix error: 'InstanceFactoryChoice' object has no attribute 'object' (#…
Browse files Browse the repository at this point in the history
…1989)

Fixed the error mentioned in issue #1988.

Co-authored-by: cw <wangchen@zhejianglab.com>
  • Loading branch information
hopeful0 and hopeful0 authored Mar 20, 2023
1 parent 838d8c4 commit 86927f5
Showing 1 changed file with 7 additions and 6 deletions.
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

0 comments on commit 86927f5

Please sign in to comment.