Skip to content

Commit 9fa14b0

Browse files
committed
Fix relative imports
1 parent 81c1e0a commit 9fa14b0

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

arduino_logique.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
draw a breadboard, etc.
66
"""
77

8+
from pathlib import Path
89
import tkinter as tk
910
from tkinter import font
1011
from breadboard import Breadboard
1112
from component_sketch import ComponentSketcher
1213
from menus import Menus
1314
from sidebar import Sidebar
1415
from toolbar import Toolbar
16+
from utils import resource_path
1517

1618

1719
def main():
@@ -60,7 +62,7 @@ def main():
6062
# Creating the Sidebar instance after canvas, board, sketcher, component_data are defined
6163
sidebar = Sidebar(
6264
parent=win,
63-
chip_images_path="Assets/chips",
65+
chip_images_path=Path(resource_path("Assets/chips")).resolve(),
6466
canvas=canvas,
6567
sketcher=sketcher,
6668
current_dict_circuit=sketcher.current_dict_circuit,

arduino_logique.spec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ exe = EXE(
3232
target_arch=None,
3333
codesign_identity=None,
3434
entitlements_file=None,
35-
contents_directory='.',
3635
)
3736
coll = COLLECT(
3837
exe,

toolbar.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import os
1414
from component_sketch import ComponentSketcher
1515
from dataCDLT import INPUT, OUTPUT, FREE
16+
from utils import resource_path
1617

1718

1819
@dataclass
@@ -94,7 +95,7 @@ def load_images(self) -> dict[str, tk.PhotoImage | None]:
9495
Loads PNG images from the 'icons' folder, scales them, and stores them in the images dictionary.
9596
"""
9697
icon_names = ["connection", "power", "input", "output", "delete"]
97-
icons_folder = Path("assets/icons").resolve()
98+
icons_folder = Path(resource_path("assets/icons")).resolve()
9899
images: dict[str, tk.PhotoImage | None] = {}
99100
for name in icon_names:
100101
path = os.path.join(icons_folder, f"{name}.png")

utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import os
2+
3+
4+
def resource_path(relative_path: str) -> str:
5+
new_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), relative_path)
6+
print("new_path:", new_path)
7+
return new_path

0 commit comments

Comments
 (0)