File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44from colorama import Fore
55from typing import Any
66from dataclasses import dataclass
7+ from path_resolver import resource_path
78
89
910class Key :
@@ -17,10 +18,14 @@ class Key:
1718 white_key_pressed_path : Path = Path ("game" , "assets" , "white_pressed.png" )
1819 black_key_pressed_path : Path = Path ("game" , "assets" , "black_pressed.png" )
1920
20- white_key : pg .Surface = pg .image .load (white_key_path )
21- black_key : pg .Surface = pg .image .load (black_key_path )
22- white_key_pressed : pg .Surface = pg .image .load (white_key_pressed_path )
23- black_key_pressed : pg .Surface = pg .image .load (black_key_pressed_path )
21+ white_key : pg .Surface = pg .image .load (resource_path (str (white_key_path )))
22+ black_key : pg .Surface = pg .image .load (resource_path (str (black_key_path )))
23+ white_key_pressed : pg .Surface = pg .image .load (
24+ resource_path (str (white_key_pressed_path ))
25+ )
26+ black_key_pressed : pg .Surface = pg .image .load (
27+ resource_path (str (black_key_pressed_path ))
28+ )
2429
2530 white_keys_padding_pixels : int = 4
2631 white_key_full_width : int = white_key .get_width () + white_keys_padding_pixels
Original file line number Diff line number Diff line change 1+ import sys
2+ from pathlib import Path
3+
4+
5+ def resource_path (relative_path : str ) -> Path :
6+ base_path = Path (getattr (sys , "_MEIPASS" , Path (__file__ ).parent ))
7+ return base_path / relative_path
Original file line number Diff line number Diff line change 11from PyQt6 import QtGui , QtWidgets , QtCore
2+ from path_resolver import resource_path
23from dataclasses import dataclass
34from pathlib import Path
45import pyqt .main_ui as ui
@@ -21,7 +22,7 @@ def __init__(self) -> None:
2122 self .ui .setupUi (self .window )
2223
2324 self .icon_path : Path = Path ("misc" , "buzzer.icon" )
24- self .window .setWindowIcon (QtGui .QIcon (str (self .icon_path )))
25+ self .window .setWindowIcon (QtGui .QIcon (str (resource_path ( str ( self .icon_path )) )))
2526
2627 self .ui .done_button .pressed .connect (self ._on_connect_button_pressed )
2728
You can’t perform that action at this time.
0 commit comments