From 176a73389a61f91724c7546b2b186ced11743119 Mon Sep 17 00:00:00 2001 From: abbou169 Date: Tue, 12 Nov 2024 22:10:10 -0500 Subject: [PATCH] improvement to the pin_ios and a bug fix --- component_sketch.py | 46 ++++++++++++++++++++++----------------------- menus.py | 8 ++++---- toolbar.py | 3 --- 3 files changed, 27 insertions(+), 30 deletions(-) diff --git a/component_sketch.py b/component_sketch.py index b6a07da..1f7f2ef 100644 --- a/component_sketch.py +++ b/component_sketch.py @@ -2564,17 +2564,17 @@ def draw_pin_io(self, x_distance, y_distance, scale=1, width=-1, direction=HORIZ self.canvas.tag_raise(element_id) # take the last number of the element_id as the pin number as an integer - pin_number = element_id.split("_")[-1] + pin_number = element_id.rsplit('_', maxsplit=1)[-1] label_x = x_distance + x_origin + 5 * scale, - label_y = y_distance + y_origin - 48 * scale, + label_y = y_distance + y_origin - 17 * scale, label_tag = f"{element_id}_label" text_id = self.canvas.create_text( label_x, label_y, text=pin_number, - font=("FiraCode-Bold", int(10 * scale)), + font=("FiraCode-Bold", int(7 * scale)), fill="#000000", anchor="center", tags=(element_id, label_tag), @@ -2584,16 +2584,16 @@ def draw_pin_io(self, x_distance, y_distance, scale=1, width=-1, direction=HORIZ if element_type == INPUT: # Arrow pointing down - arrow_line_id = self.canvas.create_line( - x_distance + x_origin + 5 * scale, - y_distance + y_origin - 23 * scale, - x_distance + x_origin + 5 * scale, - y_distance + y_origin - 13 * scale, - fill="#404040", - width=2 * thickness, - tags=(element_id, interactive_tag), - ) - params["tags"].append(arrow_line_id) + # arrow_line_id = self.canvas.create_line( + # x_distance + x_origin + 5 * scale, + # y_distance + y_origin - 23 * scale, + # x_distance + x_origin + 5 * scale, + # y_distance + y_origin - 13 * scale, + # fill="#404040", + # width=2 * thickness, + # tags=(element_id, interactive_tag), + # ) + # params["tags"].append(arrow_line_id) arrow_head_id = self.canvas.create_polygon( x_distance + x_origin + 0 * scale, @@ -2609,16 +2609,16 @@ def draw_pin_io(self, x_distance, y_distance, scale=1, width=-1, direction=HORIZ params["tags"].append(arrow_head_id) elif element_type == OUTPUT: # Arrow pointing up - arrow_line_id = self.canvas.create_line( - x_distance + x_origin + 5 * scale, - y_distance + y_origin - 23 * scale, - x_distance + x_origin + 5 * scale, - y_distance + y_origin - 13 * scale, - fill="#000000", - width=2 * thickness, - tags=(element_id, interactive_tag), - ) - params["tags"].append(arrow_line_id) + # arrow_line_id = self.canvas.create_line( + # x_distance + x_origin + 5 * scale, + # y_distance + y_origin - 23 * scale, + # x_distance + x_origin + 5 * scale, + # y_distance + y_origin - 13 * scale, + # fill="#000000", + # width=2 * thickness, + # tags=(element_id, interactive_tag), + # ) + # params["tags"].append(arrow_line_id) arrow_head_id = self.canvas.create_polygon( x_distance + x_origin + 0 * scale, diff --git a/menus.py b/menus.py index ece8c5b..b840946 100644 --- a/menus.py +++ b/menus.py @@ -208,13 +208,13 @@ def show_correspondence_table(self): # Populate the table with input and output pin mappings for idx, pin_io in enumerate(input_pin_ios): mcu_pin = input_pins[idx] - last_letter = pin_io["id"][-1] - tree.insert("", "end", values=(last_letter, "Input", mcu_pin)) + pin_number = pin_io["id"].split("_")[-1] + tree.insert("", "end", values=(pin_number, "Input", mcu_pin)) for idx, pin_io in enumerate(output_pin_ios): mcu_pin = output_pins[idx] - last_letter = pin_io["id"][-1] - tree.insert("", "end", values=(last_letter, "Output", mcu_pin)) + pin_number = pin_io["id"].split("_")[-1] + tree.insert("", "end", values=(pin_number, "Output", mcu_pin)) # Add a scrollbar if the list gets too long scrollbar = ttk.Scrollbar(table_window, orient="vertical", command=tree.yview) diff --git a/toolbar.py b/toolbar.py index 8fbac54..2d1dac3 100644 --- a/toolbar.py +++ b/toolbar.py @@ -52,7 +52,6 @@ def __init__(self, parent: tk.Tk, canvas: tk.Canvas, sketcher: ComponentSketcher self.canvas.bind("", self.canvas_follow_mouse, add="+") self.canvas.bind("", self.canvas_click, add="+") self.canvas.bind("", self.cancel_placement, add="+") - self.pin_io_list: list[dict[str, int]] = [] def create_topbar(self, parent: tk.Tk): """ @@ -340,8 +339,6 @@ def canvas_click(self, event): ) ] self.sketcher.circuit(x_origin, y_origin, model=model_pin_io) - pin_io_id = self.current_dict_circuit["last_id"] - self.pin_io_list.append({"id": pin_io_id, "type": type_const}) # Optionally deactivate after placement # self.cancel_pin_io_placement()