Skip to content

Commit eb35a07

Browse files
Refactor: Implement robust path finding for logo assets across multiple GUIs to enhance compatibility and maintainability.
1 parent a681ebc commit eb35a07

5 files changed

Lines changed: 36 additions & 29 deletions

File tree

Delta_mode_Keithley_6221_2182A/Delta_Lakeshore_Frontend_Passive_V1.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,13 @@ class MeasurementAppGUI:
142142
"""The main GUI application class (Front End)."""
143143
PROGRAM_VERSION = "8.0"
144144
LOGO_SIZE = 110
145-
LOGO_FILE_PATH = "UGC_DAE_CSR.jpeg" # Local file as per original script
145+
try:
146+
# Robust path finding for assets
147+
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
148+
LOGO_FILE_PATH = os.path.join(SCRIPT_DIR, "..", "_assets", "LOGO", "UGC_DAE_CSR.jpeg")
149+
except NameError:
150+
# Fallback for environments where __file__ is not defined
151+
LOGO_FILE_PATH = "../_assets/LOGO/UGC_DAE_CSR.jpeg"
146152

147153
# --- Theming and Styling (from 6517B...V12) ---
148154
CLR_BG_DARK = '#2B3D4F'

Delta_mode_Keithley_6221_2182A/Delta_Mode_Active_Temp_Control_V2.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,12 @@ def close_instruments(self):
146146
class Advanced_Delta_GUI:
147147
PROGRAM_VERSION = "2.0"
148148
LOGO_SIZE = 110
149-
LOGO_FILE_PATH = resource_path("_assets/UGC_DAE_CSR.jpeg")
149+
try:
150+
# Robust path finding for assets relative to the script's location
151+
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
152+
LOGO_FILE_PATH = os.path.join(SCRIPT_DIR, "..", "_assets", "LOGO", "UGC_DAE_CSR.jpeg")
153+
except NameError:
154+
LOGO_FILE_PATH = resource_path("../_assets/LOGO/UGC_DAE_CSR.jpeg")
150155

151156
CLR_BG_DARK = '#2B3D4F'; CLR_HEADER = '#3A506B'; CLR_FG_LIGHT = '#EDF2F4'
152157
CLR_TEXT_DARK = '#1A1A1A'; CLR_ACCENT_GOLD = '#FFC107'; CLR_ACCENT_GREEN = '#A7C957'

Keithley_2400/Frontend_IV_2400_V3.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,13 @@ class MeasurementAppGUI:
136136
FONT_SIZE_BASE = 12
137137
FONT_BASE = ('Segoe UI', FONT_SIZE_BASE)
138138
FONT_TITLE = ('Segoe UI', FONT_SIZE_BASE + 2, 'bold')
139-
LOGO_FILE = "UGC_DAE_CSR.jpeg"
139+
try:
140+
# Robust path finding for assets
141+
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
142+
LOGO_FILE = os.path.join(SCRIPT_DIR, "..", "_assets", "LOGO", "UGC_DAE_CSR.jpeg")
143+
except NameError:
144+
# Fallback for environments where __file__ is not defined
145+
LOGO_FILE = "../_assets/LOGO/UGC_DAE_CSR.jpeg"
140146
LOGO_SIZE = 120
141147

142148
def __init__(self, root):

Keithley_2400/Frontend_Keithley_2400_Lakeshore_350_V_vs_T_V1.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,13 @@ class TemperatureIVGUI:
105105
CLR_ACCENT_GREEN, CLR_ACCENT_RED, CLR_ACCENT_BLUE = '#A7C957', '#EF233C', '#8D99AE'
106106
CLR_CONSOLE_BG = '#1E2B38'
107107
FONT_BASE = ('Segoe UI', 10); FONT_TITLE = ('Segoe UI', 12, 'bold')
108-
LOGO_FILE = "UGC_DAE_CSR.jpeg"
108+
try:
109+
# Robust path finding for assets
110+
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
111+
LOGO_FILE = os.path.join(SCRIPT_DIR, "..", "_assets", "LOGO", "UGC_DAE_CSR.jpeg")
112+
except NameError:
113+
# Fallback for environments where __file__ is not defined
114+
LOGO_FILE = "../_assets/LOGO/UGC_DAE_CSR.jpeg"
109115

110116
def __init__(self, root):
111117
self.root = root

Keithley_6517B/Pyroelectricity/Pyroelectric_Measurement_GUI_V1.py

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,6 @@
66
# Created: 17/09/2025
77
# Version: V2.5 (Matplotlib Style Fix)
88
# -------------------------------------------------------------------------------
9-
'''
10-
===============================================================================
11-
PROGRAM: Pyroelectric Measurement GUI
12-
13-
PURPOSE: Perform a pyroelectric current measurement with two-stage
14-
temperature ramp control.
15-
16-
DESCRIPTION: This program provides a graphical user interface (GUI) for
17-
automating a pyroelectric current measurement. It integrates a
18-
Lakeshore 350 for temperature control and a Keithley 6517B for
19-
sensitive current measurement. The experiment involves a
20-
two-stage process: first stabilizing at a start temperature,
21-
then ramping to an end temperature while logging data. The GUI
22-
features live plotting and a detailed console.
23-
24-
AUTHOR: Prathamesh Deshmukh
25-
GUIDED BY: Dr. Sudip Mukherjee
26-
INSTITUTE: UGC-DAE Consortium for Scientific Research, Mumbai Centre
27-
28-
VERSION: 2.5
29-
LAST EDITED: 04/10/2025
30-
===============================================================================
31-
'''
329

3310
# --- Packages for Front end ---
3411
import tkinter as tk
@@ -245,8 +222,15 @@ def create_info_frame(self, parent):
245222

246223
logo_canvas = Canvas(frame, width=100, height=100, bg=self.CLR_BG_DARK, highlightthickness=0)
247224
logo_canvas.grid(row=0, column=0, rowspan=2, padx=15, pady=15)
248-
self.logo_image = self._process_logo_image("logo.png")
249-
if self.logo_image: logo_canvas.create_image(50, 50, image=self.logo_image)
225+
226+
# Corrected logo path
227+
try:
228+
script_dir = os.path.dirname(os.path.abspath(__file__))
229+
logo_path = os.path.join(script_dir, "..", "..", "_assets", "LOGO", "UGC_DAE_CSR.jpeg")
230+
except NameError:
231+
logo_path = "../../_assets/LOGO/UGC_DAE_CSR.jpeg"
232+
self.logo_image = self._process_logo_image(logo_path)
233+
if self.logo_image: logo_canvas.create_image(50, 50, image=self.logo_image)
250234
else: logo_canvas.create_text(50, 50, text="LOGO", font=self.FONT_TITLE, fill=self.CLR_FG_LIGHT)
251235

252236
# --- UPDATED: Added Institute Name ---

0 commit comments

Comments
 (0)