Merge pull request #606 from MikeTheWatchGuy/Dev-latest

Tree Update function - added ability to update individual node using key
This commit is contained in:
MikeTheWatchGuy 2018-10-30 12:55:54 -04:00 committed by GitHub
commit 266d3c92b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 16 deletions

View File

@ -2576,17 +2576,25 @@ class Tree(Element):
self.add_treeview_data(node) self.add_treeview_data(node)
def Update(self, values=None): def Update(self, values=None, key=None, value=None, text=None):
if values is None: if values is not None:
return children = self.TKTreeview.get_children()
children = self.TKTreeview.get_children() for i in children:
for i in children: self.TKTreeview.detach(i)
self.TKTreeview.detach(i) self.TKTreeview.delete(i)
self.TKTreeview.delete(i) children = self.TKTreeview.get_children()
children = self.TKTreeview.get_children() self.TreeData = values
self.TreeData = values self.add_treeview_data(self.TreeData.root_node)
self.add_treeview_data(self.TreeData.root_node) self.SelectedRows = []
self.SelectedRows = [] if key is not None:
item = self.TKTreeview.item(key)
if value is not None:
self.TKTreeview.item(key, values=value)
if text is not None:
self.TKTreeview.item(key, text=text)
item = self.TKTreeview.item(key)
return self
def __del__(self): def __del__(self):
super().__del__() super().__del__()
@ -2618,11 +2626,6 @@ class TreeData(object):
parent_node = self.tree_dict[parent] parent_node = self.tree_dict[parent]
parent_node._Add(node) parent_node._Add(node)
# def _print_node(self, node):
# # print(f'Node: {node.text}')
# # print(f'Children = {[c.text for c in node.children]}')
# for node in node.children:
# self._print_node(node)
def __repr__(self): def __repr__(self):
return self._NodeStr(self.root_node, 1) return self._NodeStr(self.root_node, 1)