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