예제 #1
0
def tree_widget(group, expand, level):
    import ipytree

    result = ipytree.Tree()
    root = TreeNode(group, level=level)
    result.add_node(tree_widget_sublist(root, root=True, expand=expand))

    return result
예제 #2
0
def tree_widget(group, expand, level):
    try:
        import ipytree
    except ImportError as error:
        raise ImportError(
            "{}: Run `pip install zarr[jupyter]` or `conda install ipytree`"
            "to get the required ipytree dependency for displaying the tree "
            "widget. If using jupyterlab<3, you also need to run "
            "`jupyter labextension install ipytree`".format(error))

    result = ipytree.Tree()
    root = TreeNode(group, level=level)
    result.add_node(tree_widget_sublist(root, root=True, expand=expand))

    return result
예제 #3
0
    def _tree_default(self):
        tree = ipt.Tree()
        node1 = MPLNode(name='one')
        node2 = MPLNode(name='two')
        node3 = K3DNode(name='three')
        node4 = K3DNode(name='four', nodes=[node3])
        node5 = K3DNode(name='five', nodes=[node4])
        tree.add_node(node1)
        tree.add_node(node2)
        tree.add_node(node5)

        for node in [node1, node2, node3, node4, node5]:
            node.observe(self.node_selected, 'selected')

        return tree
예제 #4
0
    def _get_tree_pane(self):
        # provide a method scanning the tree of the model
        # components
        tree_layout = ipw.Layout(display='flex',
                                 overflow='scroll hidden',
                                 flex_flow='column',
                                 border='solid 1px black',
                                 margin='0px 5px 5px 0px',
                                 padding='1px 1px 15px 1px',
                                 align_items='stretch',
                                 flex_grow="2",
                                 height="30%",
                                 width='100%')

        tree_pane = ipt.Tree(layout=tree_layout)
        root_node = self.model_tree
        tree_pane.nodes = (root_node, )
        return tree_pane