MCPcopy Index your code
hub / github.com/rawpython/remi / InstancesTree

Class InstancesTree

editor/editor_widgets.py:24–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22
23
24class InstancesTree(gui.TreeView):
25 def __init__(self, **kwargs):
26 super(InstancesTree, self).__init__(**kwargs)
27
28 def append_instance(self, instance, parent):
29 item = gui.TreeItem(instance.variable_name)
30 if parent == None:
31 parent = self
32 item.instance = instance
33 item.onclick.do(self.on_tree_item_selected, js_stop_propagation=True)
34 parent.append(item)
35 return item
36
37 def select_instance(self, node, instance):
38 if not hasattr(node, 'attributes'):
39 return
40 if node.identifier != self.identifier:
41 if hasattr(node, 'instance'):
42 if node.instance.identifier == instance.identifier:
43 node.style['background-color'] = 'lightblue'
44 else:
45 node.style['background-color'] = 'white'
46 node.attributes['treeopen'] = 'true'
47 for item in node.children.values():
48 self.select_instance(item, instance)
49
50 @gui.decorate_event
51 def on_tree_item_selected(self, emitter):
52 self.select_instance(self, emitter.instance)
53 return (emitter.instance,)
54
55 def append_instances_from_tree(self, node, parent=None):
56 if not hasattr(node, 'attributes'):
57 return
58 if not (hasattr(node, 'variable_name') and not node.variable_name is None):
59 return
60 nodeTreeItem = self.append_instance(node, parent)
61 for child in node.children.values():
62 self.append_instances_from_tree(child, nodeTreeItem)
63
64
65class InstancesWidget(gui.VBox):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected