Skip to content

Commit 378bd59

Browse files
docs path fixed locally , fresh need testing
1 parent 161842a commit 378bd59

1 file changed

Lines changed: 22 additions & 9 deletions

File tree

pica/main.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,26 @@ def launch_plotter_utility():
7171

7272

7373
def resource_path(relative_path):
74-
""" Get absolute path to resource, works for dev and for PyInstaller """
74+
"""
75+
Get absolute path to resource, works for dev and for PyInstaller.
76+
It checks for resources in the application's root directory when running
77+
from source, and within the package directory when installed.
78+
"""
7579
try:
76-
# PyInstaller creates a temp folder and stores path in _MEIPASS
7780
base_path = sys._MEIPASS
81+
return os.path.join(base_path, relative_path)
7882
except Exception:
79-
base_path = os.path.abspath(os.path.dirname(__file__))
80-
return os.path.join(base_path, relative_path)
83+
script_dir = os.path.dirname(os.path.abspath(__file__))
84+
85+
installed_path = os.path.join(script_dir, relative_path)
86+
if os.path.exists(installed_path):
87+
return installed_path
88+
89+
dev_path = os.path.join(script_dir, '..', relative_path)
90+
if os.path.exists(dev_path):
91+
return dev_path
92+
93+
return installed_path
8194

8295

8396
class PICALauncherApp:
@@ -103,10 +116,10 @@ class PICALauncherApp:
103116
FONT_INFO = ('Segoe UI', FONT_SIZE_BASE)
104117
FONT_INFO_ITALIC = ('Segoe UI', FONT_SIZE_BASE, 'italic')
105118
LOGO_FILE = resource_path("assets/LOGO/UGC_DAE_CSR_NBG.jpeg")
106-
MANUAL_FILE = resource_path("../docs/User_Manual.md")
107-
README_FILE = resource_path("../README.md")
108-
LICENSE_FILE = resource_path("../LICENSE")
109-
UPDATES_FILE = resource_path("../CHANGELOG.md")
119+
MANUAL_FILE = resource_path("docs/User_Manual.md")
120+
README_FILE = resource_path("README.md")
121+
LICENSE_FILE = resource_path("LICENSE")
122+
UPDATES_FILE = resource_path("CHANGELOG.md")
110123
REPO_URL = "https://github.com/prathameshnium/PICA-Python-Instrument-Control-and-Automation/tree/main"
111124
LOGO_SIZE = 140
112125

@@ -131,7 +144,7 @@ class PICALauncherApp:
131144
"Lakeshore Temp Monitor": resource_path("lakeshore/T_Sensing_L350_GUI.py"),
132145
"LCR C-V Measurement": resource_path("keysight/CV_KE4980A_GUI.py"),
133146
"Plotter Utility": resource_path("utils/PlotterUtil_GUI.py"),
134-
"PICA Help": resource_path("../README.md"),
147+
"PICA Help": resource_path("README.md"),
135148
}
136149

137150
def __init__(self, root):

0 commit comments

Comments
 (0)