diff --git a/arduino_logique.py b/arduino_logique.py index 78260f9..ba425c9 100644 --- a/arduino_logique.py +++ b/arduino_logique.py @@ -2,7 +2,7 @@ ArduinoLogique.py Main module for the ArduinoLogique program. This module provides a graphical interface for simulating logic circuits using Tkinter. It includes functionality to initialize a canvas, -draw a breadboard, and zoom in and out on the circuit diagram. +draw a breadboard, etc. """ import tkinter as tk @@ -14,32 +14,6 @@ from toolbar import Toolbar -def zoom(canvas: tk.Canvas, scale: float, sketcher: ComponentSketcher) -> None: - """ - Adjusts the zoom level of the given canvas by scaling the board and updating the scale factor. - - Parameters: - - canvas (tk.Canvas): The canvas on which the board is drawn. - - scale (float): The scale factor to apply to the board. - - sketcher (ComponentSketcher): The ComponentSketcher instance used to draw the circuit. - - Returns: - - None - """ - # Calculate the scaling factor - new_scale_factor = scale / 10.0 - scale_ratio = new_scale_factor / sketcher.scale_factor - - # Update the scale factor in the existing ComponentSketcher instance - sketcher.scale_factor = new_scale_factor - - # Scale all items on the canvas - canvas.scale("all", 0, 0, scale_ratio, scale_ratio) - - # Optionally, you may need to adjust the canvas scroll region or other properties - canvas.configure(scrollregion=canvas.bbox("all")) - - def main(): """ Main function for the ArduinoLogique program. This function initializes the main window, @@ -48,7 +22,8 @@ def main(): # Creating main window win = tk.Tk() win.title("Laboratoire virtuel de circuit logique - GIF-1002") - win.geometry("1600x900") # Initial window size + win.geometry("1400x800") # Initial window size + win.resizable(False, False) # Disabling window resizing win.configure(bg="#333333") # Setting consistent background color # Configuring grid layout for the main window @@ -105,34 +80,10 @@ def refresh_sidebar(): canvas=canvas, board=board, current_dict_circuit=sketcher.current_dict_circuit, - zoom_function=zoom, ) # Placing the menu_bar in row=0, spanning both columns menus.menu_bar.grid(row=0, column=0, columnspan=2, sticky="nsew") - # Assigning the references to menus - menus.zoom_function = zoom - - # Creating a slider and placing it in row=3, spanning both columns - h_slider = tk.Scale( - win, - from_=10, - to=30, - orient="horizontal", - command=lambda scale: zoom(canvas, float(scale), sketcher), - bg="#333333", - fg="white", - activebackground="#444444", - troughcolor="#555555", - highlightbackground="#333333", - sliderrelief="flat", - bd=0, - highlightthickness=0, - ) - h_slider.set(10) # Setting initial slider value - - h_slider.grid(row=3, column=0, columnspan=2, sticky="ew", padx=0, pady=0) - # Setting default font for all widgets default_font = font.Font(family="Arial", size=10) win.option_add("*Font", default_font) diff --git a/menus.py b/menus.py index 1e4213a..4c7205c 100644 --- a/menus.py +++ b/menus.py @@ -63,7 +63,6 @@ class Menus: board (Breadboard): The Breadboard instance. model (list): The model data for the circuit. current_dict_circuit (dict): The current circuit data. - zoom (Callable): The zoom function to adjust the canvas. com_port (str | None): The selected COM port. """ @@ -73,7 +72,6 @@ def __init__( canvas: tk.Canvas, board: Breadboard, current_dict_circuit: dict, - zoom_function: Callable, ): """ Initializes the custom menu bar. @@ -82,8 +80,6 @@ def __init__( - parent (tk.Tk or tk.Frame): The main window or parent frame. - canvas (tk.Canvas): The canvas widget for drawing circuits. - board (Breadboard): The Breadboard instance. - - current_dict_circuit (dict): The current circuit data. - - zoom_function (callable): The zoom function to adjust the canvas. """ self.parent: tk.Tk | tk.Frame = parent """The main window or parent frame.""" @@ -93,8 +89,6 @@ def __init__( """The Breadboard instance.""" self.current_dict_circuit: dict = current_dict_circuit """The current circuit data.""" - self.zoom: Callable = zoom_function - """The zoom function to adjust the canvas.""" self.com_port: str | None = None """The selected COM port.""" self.selected_microcontroller = None @@ -359,7 +353,6 @@ def open_file(self): # Update current_dict_circuit and redraw the circuit self.board.sketcher.clear_board() - # self.zoom(self.canvas, 10.0, self.board, 50, 10, []) x_o, y_o = self.board.sketcher.id_origins["xyOrigin"] self.board.sketcher.circuit(x_o, y_o, model=[])