Skip to content

Commit 77cf7bd

Browse files
authored
Merge e1ec96f into 7bf0af5
2 parents 7bf0af5 + e1ec96f commit 77cf7bd

File tree

5 files changed

+47
-28
lines changed

5 files changed

+47
-28
lines changed

.github/workflows/release_pipeline.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ jobs:
2121
python-version: '3.x'
2222

2323
- name: Install PyInstaller
24-
run: pip install pyinstaller pyserial
24+
run: pip install pyinstaller pyserial tkmacosx
2525

2626
- name: Build with PyInstaller
2727
run: pyinstaller arduino_logique.spec
2828

2929
- name: Compress the build
3030
run: |
3131
cd dist
32-
tar -czvf arduino_logique_macos.tar.gz arduino_logique
32+
tar -chzvf arduino_logique_macos.tar.gz arduino_logique
3333
3434
- name: Upload artifact
3535
uses: actions/upload-artifact@v3

Assets/Icons/clock.png

1.5 KB
Loading

menus.py

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@
88
from dataclasses import dataclass
99
import os
1010
import tkinter as tk
11-
from tkinter import messagebox, filedialog, ttk
1211
import json
1312
import subprocess
1413
import platform
15-
from typing import Callable
1614
import serial.tools.list_ports # type: ignore
1715

1816
from breadboard import Breadboard
1917

20-
from dataCDLT import INPUT, OUTPUT, USED, CLOCK
18+
from dataCDLT import INPUT, OUTPUT, CLOCK
19+
20+
if os.name == "darwin":
21+
from tkinter import messagebox, filedialog, ttk
22+
from tkmacosx import Button # type: ignore
23+
else:
24+
from tkinter import Button, messagebox, filedialog, ttk
2125

2226
MICROCONTROLLER_PINS = {
2327
"Arduino Mega": {
@@ -181,13 +185,15 @@ def confirm_selection():
181185
self.microcontroller_label.config(text=self.selected_microcontroller)
182186
dialog.destroy()
183187

184-
confirm_button = tk.Button(dialog, text="Confirmer", command=confirm_selection)
188+
confirm_button = Button(dialog, text="Confirmer", command=confirm_selection)
185189
confirm_button.pack(pady=10)
186190

187191
def show_correspondence_table(self):
188192
"""Displays the correspondence table between pin_io objects and microcontroller pins in a table format."""
189193
if self.selected_microcontroller is None:
190-
messagebox.showwarning("Aucun microcontrôleur sélectionné", "Veuillez d'abord sélectionner un microcontrôleur.")
194+
messagebox.showwarning(
195+
"Aucun microcontrôleur sélectionné", "Veuillez d'abord sélectionner un microcontrôleur."
196+
)
191197
return
192198

193199
pin_mappings = MICROCONTROLLER_PINS.get(self.selected_microcontroller)
@@ -279,7 +285,7 @@ def create_menu(self, menu_name, options, menu_commands):
279285
- options (list): List of options under the menu.
280286
"""
281287
# Create the menu button
282-
btn = tk.Button(
288+
btn = Button(
283289
self.menu_bar,
284290
text=menu_name,
285291
bg="#333333",
@@ -312,7 +318,7 @@ def select_menu_item(option):
312318

313319
# Populate the dropdown with menu options
314320
for option in options:
315-
option_btn = tk.Button(
321+
option_btn = Button(
316322
dropdown,
317323
text=option,
318324
bg="#333333",
@@ -343,7 +349,7 @@ def toggle_dropdown(self, menu_name):
343349
- menu_name (str): The name of the menu to toggle.
344350
"""
345351
for child in self.menu_bar.winfo_children():
346-
if isinstance(child, tk.Button) and hasattr(child, "dropdown"):
352+
if isinstance(child, Button) and hasattr(child, "dropdown"):
347353
if child["text"] == menu_name:
348354
if child.dropdown.winfo_ismapped():
349355
child.dropdown.place_forget()
@@ -387,11 +393,11 @@ def close_dropdown(self, event):
387393
and not any(
388394
self.is_descendant(event.widget, child.dropdown)
389395
for child in self.menu_bar.winfo_children()
390-
if isinstance(child, tk.Button) and hasattr(child, "dropdown")
396+
if isinstance(child, Button) and hasattr(child, "dropdown")
391397
)
392398
):
393399
for child in self.menu_bar.winfo_children():
394-
if isinstance(child, tk.Button) and hasattr(child, "dropdown"):
400+
if isinstance(child, Button) and hasattr(child, "dropdown"):
395401
child.dropdown.place_forget()
396402

397403
# Menu Handler Functions
@@ -424,9 +430,9 @@ def open_file(self):
424430

425431
for key, val in circuit_data.items():
426432
if key == "_battery_pos_wire":
427-
battery_pos_wire_end = val['end']
433+
battery_pos_wire_end = val["end"]
428434
elif key == "_battery_neg_wire":
429-
battery_neg_wire_end = val['end']
435+
battery_neg_wire_end = val["end"]
430436

431437
self.board.draw_blank_board_model(
432438
x_o,
@@ -451,7 +457,9 @@ def open_file(self):
451457
messagebox.showinfo("Ouvrir un fichier", f"Circuit chargé depuis {file_path}")
452458
except Exception as e:
453459
print(f"Error loading file: {e}")
454-
messagebox.showerror("Erreur d'ouverture", f"Une erreur s'est produite lors de l'ouverture du fichier:\n{e}")
460+
messagebox.showerror(
461+
"Erreur d'ouverture", f"Une erreur s'est produite lors de l'ouverture du fichier:\n{e}"
462+
)
455463
raise e
456464
else:
457465
print("Open file cancelled.")
@@ -529,7 +537,7 @@ def save_file(self):
529537
if "label" in comp_data:
530538
comp_data["label"] = comp_data["type"]
531539
if "wire" in key:
532-
comp_data.pop("XY", None) # Remove XY, will be recalculated anyway
540+
comp_data.pop("XY", None) # Remove XY, will be recalculated anyway
533541
if key == "_battery":
534542
comp_data.pop("battery_rect", None)
535543
# Save the data to a JSON file
@@ -539,7 +547,9 @@ def save_file(self):
539547
messagebox.showinfo("Sauvegarde réussie", f"Circuit sauvegardé dans {file_path}")
540548
except (TypeError, KeyError) as e:
541549
print(f"Error saving file: {e}")
542-
messagebox.showerror("Erreur de sauvegarde", f"Une erreur s'est produite lors de la sauvegarde du fichier:\n{e}")
550+
messagebox.showerror(
551+
"Erreur de sauvegarde", f"Une erreur s'est produite lors de la sauvegarde du fichier:\n{e}"
552+
)
543553
else:
544554
print("Save file cancelled.")
545555

@@ -568,7 +578,7 @@ def confirm_selection():
568578
self.serial_port.com_port = selected_option
569579
dialog.destroy()
570580

571-
confirm_button = tk.Button(dialog, text="Confirm", command=confirm_selection)
581+
confirm_button = Button(dialog, text="Confirm", command=confirm_selection)
572582
confirm_button.pack(pady=10)
573583

574584
def open_documentation(self):

sidebar.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from dataclasses import dataclass
88
from pathlib import Path
99
import tkinter as tk
10-
from tkinter import messagebox, font
1110
import os
1211
from typing import Callable, Tuple
1312
import subprocess
@@ -18,6 +17,12 @@
1817
from dataCDLT import FREE, USED
1918
from object_model.circuit_object_model import Chip, get_all_available_chips, get_chip_modification_times
2019

20+
if os.name == "darwin":
21+
from tkinter import messagebox, font
22+
from tkmacosx import Button # type: ignore
23+
else:
24+
from tkinter import Button, messagebox, font
25+
2126

2227
@dataclass
2328
class SidebarGrid:
@@ -217,7 +222,7 @@ def display_chips(self, chips: list[Tuple[Chip, tk.PhotoImage]]):
217222
for index, (chip, chip_image) in enumerate(display_chips):
218223
row = index // self.sidebar_grid.columns
219224
col = index % self.sidebar_grid.columns
220-
btn = tk.Button(
225+
btn = Button(
221226
self.chips_inner_frame,
222227
image=chip_image,
223228
text=chip.chip_type,
@@ -257,7 +262,7 @@ def create_manage_button(self, sidebar_frame):
257262
"""
258263
Creates the 'Manage Components' button at the bottom of the sidebar without an icon.
259264
"""
260-
manage_button = tk.Button(
265+
manage_button = Button(
261266
sidebar_frame,
262267
text="Gérer les composants",
263268
bg="#333333", # Matching the sidebar's background to simulate transparency

toolbar.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@
55
for selecting connection colors. The Toolbar class manages the state and behavior of these buttons and handles user
66
interactions for placing wires and pin_ios on a canvas.
77
"""
8-
8+
import os
99
from dataclasses import dataclass
1010
from pathlib import Path
1111
import tkinter as tk
12-
from tkinter import messagebox, colorchooser
13-
import os
12+
1413
from component_sketch import ComponentSketcher
1514
from dataCDLT import INPUT, OUTPUT, FREE, CLOCK
1615
from utils import resource_path
1716

17+
if os.name == "darwin":
18+
from tkinter import messagebox, colorchooser
19+
from tkmacosx import Button # type: ignore
20+
else:
21+
from tkinter import Button, messagebox, colorchooser
1822

1923
@dataclass
2024
class WirePlacementInfo:
@@ -45,7 +49,7 @@ def __init__(self, parent: tk.Tk, canvas: tk.Canvas, sketcher: ComponentSketcher
4549
self.sketcher = sketcher
4650
self.current_dict_circuit = current_dict_circuit
4751
self.selected_color = "#479dff"
48-
self.buttons: dict[str, tk.Button] = {}
52+
self.buttons: dict[str, Button] = {}
4953
self.tool_mode = None
5054
self.wire_info: WirePlacementInfo = WirePlacementInfo(0, None, None)
5155
self.cursor_indicator_id = None
@@ -79,7 +83,7 @@ def create_topbar(self, parent: tk.Tk):
7983
self.create_button("Clock", left_frame, images)
8084

8185
# Create the color chooser and Delete button in the right frame
82-
self.color_button = tk.Button(
86+
self.color_button = Button(
8387
right_frame,
8488
bg=self.selected_color,
8589
width=2,
@@ -129,7 +133,7 @@ def create_button(self, action: str, parent_frame: tk.Frame, images: dict[str, t
129133
"""
130134
image = images.get(action.lower())
131135
if image:
132-
btn = tk.Button(
136+
btn = Button(
133137
parent_frame,
134138
image=image,
135139
bg="#505050", # Inactive background
@@ -145,7 +149,7 @@ def create_button(self, action: str, parent_frame: tk.Frame, images: dict[str, t
145149
btn.image = image # type: ignore
146150
else:
147151
# Fallback button with text if image is not available
148-
btn = tk.Button(
152+
btn = Button(
149153
parent_frame,
150154
text=action,
151155
bg="#505050", # Inactive background

0 commit comments

Comments
 (0)