Fix des Baumviews. ChildIds wurden nicht aus dem Pool genommen
This commit is contained in:
@@ -121,7 +121,7 @@ if __name__ == '__main__':
|
||||
model = CadItem()
|
||||
if args.demo:
|
||||
model.from_json(json.loads(demo_data))
|
||||
build_gui(model, configs)
|
||||
build_gui(model, configs, "400102196", True)
|
||||
|
||||
elif args.sivasid:
|
||||
sivasid = args.sivasid.strip()
|
||||
|
||||
+24
-27
@@ -87,43 +87,40 @@ class TreeView():
|
||||
return False
|
||||
|
||||
def create(self, parent_children_mapping, red_ids):
|
||||
# adding data of first column after root
|
||||
pool = dict()
|
||||
for parent, children in parent_children_mapping.items():
|
||||
parent_text = parent
|
||||
# parent erzeugen, falls es diese nicht schon gibt
|
||||
if parent_text not in pool:
|
||||
parent_id = self.tree.insert('', tk.END, text=parent_text, open=True)
|
||||
pool[parent_text] = parent_id
|
||||
# parent erzeugen, falls es diese nicht schon gibt (check der pool ids)
|
||||
if parent not in pool:
|
||||
if parent not in red_ids: rowtags = ('good')
|
||||
else: rowtags = ('missing')
|
||||
|
||||
parent_id = self.tree.insert('', tk.END, text=parent, tags=rowtags, open=True)
|
||||
pool[parent] = parent_id
|
||||
else:
|
||||
parent_id = pool[parent_text]
|
||||
|
||||
parent_id = pool[parent]
|
||||
|
||||
for child in children:
|
||||
child_text = child
|
||||
if child_text not in red_ids: rowtags = ('good')
|
||||
else: rowtags = ('missing')
|
||||
if self._has_childs(child_text, parent_children_mapping) == True:
|
||||
if child not in red_ids: rowtags = ('good')
|
||||
else: rowtags = ('missing')
|
||||
|
||||
if self._has_childs(child, parent_children_mapping) == True:
|
||||
# wenn das Objekt ein Kind hat, könnte es bereits erzeugt worden sein
|
||||
if child_text not in pool:
|
||||
child_id = self.tree.insert('', tk.END, text=child_text, tags=rowtags, open=True)
|
||||
pool[child_text] = child_id
|
||||
self.tree.move(child_id, parent_id, 0)
|
||||
if child not in pool:
|
||||
child_id = self.tree.insert('', tk.END, text=child, tags=rowtags, open=True)
|
||||
pool[child] = child_id
|
||||
else:
|
||||
child_id = pool[child]
|
||||
else:
|
||||
# die Blätter des Baumes kann man bedenkenlos bauen
|
||||
child_id = self.tree.insert('', tk.END, text=child_text, tags=rowtags, open=True)
|
||||
self.tree.move(child_id, parent_id, 0)
|
||||
pool[child_text] = child_id
|
||||
|
||||
|
||||
|
||||
# # einmal über alles gehen und alle keys an die richtige Stelle schieben
|
||||
# for parent,children in parent_children_mapping.items():
|
||||
# for child_id in children:
|
||||
# self.tree.move(child_id, parent, 0)
|
||||
# die Blätter des Baumes kann man bedenkenlos immer bauen. Diese können redundante Texte haben.
|
||||
child_id = self.tree.insert('', tk.END, text=child, tags=rowtags, open=True)
|
||||
pool[child] = child_id
|
||||
self.tree.move(child_id, parent_id, 'end')
|
||||
|
||||
# https://www.askpython.com/python-modules/tkinter/tkinter-colors
|
||||
#self.tree.tag_configure('good', background='LawnGreen')
|
||||
self.tree.tag_configure('good', background='white')
|
||||
self.tree.tag_configure('yellow', background='yellow')
|
||||
self.tree.tag_configure('orange', background='orange')
|
||||
self.tree.tag_configure('missing', background='red')
|
||||
|
||||
def data_from_model(self):
|
||||
|
||||
Reference in New Issue
Block a user