From da013c1eda2aa920ed7f46f49889b75188386b3c Mon Sep 17 00:00:00 2001 From: Nick Moore Date: Thu, 28 Mar 2024 18:11:29 +1100 Subject: [PATCH] minor fix for incorrect options when inserting new node --- countess/gui/main.py | 2 +- countess/gui/tree.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/countess/gui/main.py b/countess/gui/main.py index 79ce2a8..5f8f14f 100644 --- a/countess/gui/main.py +++ b/countess/gui/main.py @@ -419,7 +419,7 @@ def config_new(self): self.graph_wrapper.destroy() self.graph = PipelineGraph() self.graph_wrapper = GraphWrapper(self.canvas, self.graph, self.node_select) - self.graph_wrapper.add_new_node(select=True) + self.graph_wrapper.add_new_node() def config_load(self, filename=None): if not filename: diff --git a/countess/gui/tree.py b/countess/gui/tree.py index 110b9ec..9fe9a2f 100644 --- a/countess/gui/tree.py +++ b/countess/gui/tree.py @@ -418,7 +418,7 @@ def on_canvas_button(self, event): # return position = self.new_node_position(event.x, event.y) - new_node = self.add_new_node(position) + new_node = self.add_new_node(position, select=False) for item in items: _, child_node, parent_node = self.lines_lookup[item] @@ -426,6 +426,9 @@ def on_canvas_button(self, event): self.add_parent(new_node, child_node) self.add_parent(parent_node, new_node) + self.highlight_node(new_node) + self.node_select_callback(new_node) + def on_canvas_delete(self, event): """Delete key on canvas: delete line(s).""" items = self.canvas.find_overlapping(event.x - 10, event.y - 10, event.x + 10, event.y + 10) @@ -460,7 +463,7 @@ def on_delete(self, node, event): event.widget.destroy() if len(self.graph.nodes) == 0: - self.add_new_node(select=True) + new_node = self.add_new_node(select=True) elif node == self.selected_node: # arbitrarily pick another node to show new_node = parent_nodes[0] if parent_nodes else child_nodes[0] if child_nodes else list(self.graph.nodes)[0] @@ -474,7 +477,7 @@ def find_node_at_position(self, x, y): return node return None - def add_new_node(self, position=(0.5, 0.5), select=True): + def add_new_node(self, position=(0.5, 0.5), select: bool = True): new_node = PipelineNode(name=f"NEW {len(self.graph.nodes)+1}", position=position) self.graph.add_node(new_node) self.labels[new_node] = self.label_for_node(new_node) @@ -491,7 +494,7 @@ def on_ghost_release(self, start_node, event): other_node = self.find_node_at_position(event.x + xl, event.y + yl) if other_node is None: position = self.new_node_position(event.x + xl, event.y + yl) - other_node = self.add_new_node(position) + other_node = self.add_new_node(position, select=False) elif other_node == start_node: return elif start_node in other_node.parent_nodes: