Skip to content

Commit

Permalink
minor fix for incorrect options when inserting new node
Browse files Browse the repository at this point in the history
  • Loading branch information
nickzoic committed Mar 28, 2024
1 parent 2e2b5c5 commit da013c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion countess/gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 7 additions & 4 deletions countess/gui/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,14 +418,17 @@ 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]
self.del_parent(parent_node, child_node)
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)
Expand Down Expand Up @@ -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]
Expand All @@ -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)
Expand All @@ -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:
Expand Down

0 comments on commit da013c1

Please sign in to comment.