MCPcopy
hub / github.com/PySimpleGUI/PySimpleGUI / TreeData

Class TreeData

PySimpleGUI/PySimpleGUI.py:9522–9623  ·  view source on GitHub ↗

Class that user fills in to represent their tree data. It's a very simple tree representation with a root "Node" with possibly one or more children "Nodes". Each Node contains a key, text to display, list of values to display and an icon. The entire tree is built using a single method

Source from the content-addressed store, hash-verified

9520
9521
9522class TreeData(object):
9523 """
9524 Class that user fills in to represent their tree data. It's a very simple tree representation with a root "Node"
9525 with possibly one or more children "Nodes". Each Node contains a key, text to display, list of values to display
9526 and an icon. The entire tree is built using a single method, Insert. Nothing else is required to make the tree.
9527 """
9528
9529 class Node(object):
9530 """
9531 Contains information about the individual node in the tree
9532 """
9533
9534 def __init__(self, parent, key, text, values, icon=None):
9535 """
9536 Represents a node within the TreeData class
9537
9538 :param parent: The parent Node
9539 :type parent: (TreeData.Node)
9540 :param key: Used to uniquely identify this node
9541 :type key: str | int | tuple | object
9542 :param text: The text that is displayed at this node's location
9543 :type text: (str)
9544 :param values: The list of values that are displayed at this node
9545 :type values: List[Any]
9546 :param icon: just a icon
9547 :type icon: str | bytes
9548 """
9549
9550 self.parent = parent # type: TreeData.Node
9551 self.children = [] # type: List[TreeData.Node]
9552 self.key = key # type: str
9553 self.text = text # type: str
9554 self.values = values # type: List[Any]
9555 self.icon = icon # type: str | bytes
9556
9557 def _Add(self, node):
9558 self.children.append(node)
9559
9560 def __init__(self):
9561 """
9562 Instantiate the object, initializes the Tree Data, creates a root node for you
9563 """
9564 self.tree_dict = {} # type: Dict[str, TreeData.Node]
9565 self.root_node = self.Node("", "", 'root', [], None) # The root node
9566 self.tree_dict[""] = self.root_node # Start the tree out with the root node
9567
9568 def _AddNode(self, key, node):
9569 """
9570 Adds a node to tree dictionary (not user callable)
9571
9572 :param key: Uniquely identifies this Node
9573 :type key: (str)
9574 :param node: Node being added
9575 :type node: (TreeData.Node)
9576 """
9577 self.tree_dict[key] = node
9578
9579 def insert(self, parent, key, text, values, icon=None):

Callers 1

_create_main_windowFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected