Skip to content

Commit dcb133f

Browse files
authored
Merge 6bb9fe6 into 518a5a1
2 parents 518a5a1 + 6bb9fe6 commit dcb133f

File tree

4 files changed

+34
-21
lines changed

4 files changed

+34
-21
lines changed

.github/workflows/release_pipeline.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ 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

menus.py

Lines changed: 14 additions & 10 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
18+
from dataCDLT import INPUT, OUTPUT
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": {
@@ -173,7 +177,7 @@ def confirm_selection():
173177
print(f"{selected_option} selected.")
174178
dialog.destroy()
175179

176-
confirm_button = tk.Button(dialog, text="Confirm", command=confirm_selection)
180+
confirm_button = Button(dialog, text="Confirm", command=confirm_selection)
177181
confirm_button.pack(pady=10)
178182

179183
def show_correspondence_table(self):
@@ -260,7 +264,7 @@ def create_menu(self, menu_name, options, menu_commands):
260264
- options (list): List of options under the menu.
261265
"""
262266
# Create the menu button
263-
btn = tk.Button(
267+
btn = Button(
264268
self.menu_bar,
265269
text=menu_name,
266270
bg="#333333",
@@ -293,7 +297,7 @@ def select_menu_item(option):
293297

294298
# Populate the dropdown with menu options
295299
for option in options:
296-
option_btn = tk.Button(
300+
option_btn = Button(
297301
dropdown,
298302
text=option,
299303
bg="#333333",
@@ -324,7 +328,7 @@ def toggle_dropdown(self, menu_name):
324328
- menu_name (str): The name of the menu to toggle.
325329
"""
326330
for child in self.menu_bar.winfo_children():
327-
if isinstance(child, tk.Button) and hasattr(child, "dropdown"):
331+
if isinstance(child, Button) and hasattr(child, "dropdown"):
328332
if child["text"] == menu_name:
329333
if child.dropdown.winfo_ismapped():
330334
child.dropdown.place_forget()
@@ -368,11 +372,11 @@ def close_dropdown(self, event):
368372
and not any(
369373
self.is_descendant(event.widget, child.dropdown)
370374
for child in self.menu_bar.winfo_children()
371-
if isinstance(child, tk.Button) and hasattr(child, "dropdown")
375+
if isinstance(child, Button) and hasattr(child, "dropdown")
372376
)
373377
):
374378
for child in self.menu_bar.winfo_children():
375-
if isinstance(child, tk.Button) and hasattr(child, "dropdown"):
379+
if isinstance(child, Button) and hasattr(child, "dropdown"):
376380
child.dropdown.place_forget()
377381

378382
# Menu Handler Functions
@@ -549,7 +553,7 @@ def confirm_selection():
549553
self.serial_port.com_port = selected_option
550554
dialog.destroy()
551555

552-
confirm_button = tk.Button(dialog, text="Confirm", command=confirm_selection)
556+
confirm_button = Button(dialog, text="Confirm", command=confirm_selection)
553557
confirm_button.pack(pady=10)
554558

555559
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="Manage Components",
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
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
@@ -78,7 +82,7 @@ def create_topbar(self, parent: tk.Tk):
7882
self.create_button("Output", left_frame, images)
7983

8084
# Create the color chooser and Delete button in the right frame
81-
self.color_button = tk.Button(
85+
self.color_button = Button(
8286
right_frame,
8387
bg=self.selected_color,
8488
width=2,
@@ -128,7 +132,7 @@ def create_button(self, action: str, parent_frame: tk.Frame, images: dict[str, t
128132
"""
129133
image = images.get(action.lower())
130134
if image:
131-
btn = tk.Button(
135+
btn = Button(
132136
parent_frame,
133137
image=image,
134138
bg="#505050", # Inactive background
@@ -144,7 +148,7 @@ def create_button(self, action: str, parent_frame: tk.Frame, images: dict[str, t
144148
btn.image = image # type: ignore
145149
else:
146150
# Fallback button with text if image is not available
147-
btn = tk.Button(
151+
btn = Button(
148152
parent_frame,
149153
text=action,
150154
bg="#505050", # Inactive background

0 commit comments

Comments
 (0)