You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use the Tree to represent the tree-like structure of my CustomClass. I extended the Node class to contain a reference to a CustomClass instance. The goal is that when a user clicks on the Node, the Tree it's under can save the reference for another widget to link to and load the information.
importipywidgetsaswidgetsimportipytreefromtraitletsimportInstanceclassCustomClass():
""" node-like: contains a List of other CustomClasses """passclassCustomTree(ipytree.Tree):
selected_custom_class=Instance(CustomClass, allow_none=True).tag(sync=True)
def__init__(self, **kwargs):
super().__init__(multiple_selection=False, **kwargs)
self.observe(self._get_custom_ref, 'selected')
def_get_custom_ref(self, event):
# Unsure how to write/get working <-------------------------------------------event['owner'].set_trait('selected_custom_class', event['new'].node_ref)
classCustomNode(ipytree.Node):
""" Node holds a reference to CustomClass """def__init__(self, my_data: CustomClass, **kwargs):
self.my_data_ref=my_datasuper().__init__(**kwargs)
classOtherWidget(ipywidget.Tab):
""" Loads the selected Node to view. """selected_custom_class=Instance(CustomClass, allow_none=True).tag(sync=True)
# __init__, etc.# ... elsewhere in the code base ...box=widgets.HBox([custom_tree, other_widget])
widgets.link(custom_tree, 'selected_custom_class', other_widget, 'selected_custom_class')
I've tried a lot of things for _get_custom_ref, but nothing seems to run; another version of the code above was to move _get_custom_ref to CustomNode and have it trigger there, but again, I don't see any change. I can run the example jupyter notebook and modify the text just fine, but it doesn't seem to modify the custom traitlet.
Any ideas and advice would be greatly appreciated.
ipytree version: 0.2.2 ipywidgets version: 8.0.2
The text was updated successfully, but these errors were encountered:
I'm trying to use the Tree to represent the tree-like structure of my
CustomClass
. I extended theNode
class to contain a reference to aCustomClass
instance. The goal is that when a user clicks on the Node, the Tree it's under can save the reference for another widget to link to and load the information.I've tried a lot of things for
_get_custom_ref
, but nothing seems to run; another version of the code above was to move_get_custom_ref
to CustomNode and have it trigger there, but again, I don't see any change. I can run the example jupyter notebook and modify the text just fine, but it doesn't seem to modify the custom traitlet.Any ideas and advice would be greatly appreciated.
ipytree version: 0.2.2
ipywidgets version: 8.0.2
The text was updated successfully, but these errors were encountered: