Skip to content

Commit 36c12a8

Browse files
indentation error fixed
1 parent ab0cefc commit 36c12a8

1 file changed

Lines changed: 70 additions & 63 deletions

File tree

pica/main.py

Lines changed: 70 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -143,69 +143,76 @@ class PICALauncherApp:
143143
"Lakeshore Temp Control": resource_path("lakeshore/T_Control_L350_RangeControl_GUI.py"),
144144
"Lakeshore Temp Monitor": resource_path("lakeshore/T_Sensing_L350_GUI.py"),
145145
"LCR C-V Measurement": resource_path("keysight/CV_KE4980A_GUI.py"),
146-
"Plotter Utility": resource_path("utils/PlotterUtil_GUI.py"),
147-
"GPIB Scanner": resource_path("utils/GPIB_Instrument_Scanner_GUI.py"),
148-
"PICA Help": resource_path("README.md"),
149-
}
150-
151-
152-
def launch_pica_script(script_key):
153-
"""
154-
Globally accessible function to launch PICA scripts by their key.
155-
This uses the same resource_path and Process logic as PICALauncherApp
156-
to ensure consistency and correct path resolution for installed packages.
157-
"""
158-
if script_key not in PICALauncherApp.SCRIPT_PATHS:
159-
print(f"ERROR: Script key '{script_key}' not found in PICA SCRIPT_PATHS.")
160-
messagebox.showwarning(
161-
"Script Not Found",
162-
f"The script key '{script_key}' is not defined in the main application's script paths.")
163-
return
164-
165-
script_path = PICALauncherApp.SCRIPT_PATHS[script_key]
166-
print(f"Launching external script: {os.path.basename(script_path)}")
167-
abs_path = os.path.abspath(script_path)
168-
169-
if not os.path.exists(abs_path):
170-
print(f"ERROR: Script not found at {abs_path}")
171-
messagebox.showerror(
172-
"File Not Found",
173-
f"Script not found:\n\n{abs_path}")
174-
return
175-
176-
try:
177-
proc = Process(target=run_script_process, args=(abs_path,))
178-
proc.start()
179-
print(f"Successfully launched '{os.path.basename(script_path)}' in a new process.")
180-
except Exception as e:
181-
print(f"ERROR: Failed to launch script '{script_key}'. Reason: {e}")
182-
messagebox.showerror(
183-
"Launch Error",
184-
f"An error occurred while launching the script '{script_key}':\n\n{e}")
185-
def __init__(self, root):
186-
self.root = root
187-
self.root.title(f"PICA Launcher v{self.PROGRAM_VERSION}")
188-
self.root.state('zoomed') # Launch in maximized/fullscreen state
189-
self.root.configure(bg=self.CLR_BG_DARK)
190-
self.root.minsize(1200, 780)
191-
self.logo_image = None
192-
self.console_widget = None
193-
self._md_cache = {} # Cache for parsed markdown files
194-
self.setup_styles()
195-
self.create_widgets()
196-
self.log(f"PICA Launcher v{self.PROGRAM_VERSION} initialized.")
197-
self.log(
198-
f"PIL/Pillow (logo): {'Available' if PIL_AVAILABLE else 'Not found'}")
199-
self.log(
200-
f"PyVISA (GPIB test): {'Available' if PYVISA_AVAILABLE else 'Not found'}")
201-
self.log(
202-
"Welcome to PICA. Check connections and run a GPIB test before starting.")
203-
204-
# Auto-launch GPIB scanner after 1 second
205-
self.root.after(1000, self.run_gpib_test)
206-
# Pre-cache markdown files in the background for faster window opening
207-
self.root.after(1500, self._pre_cache_markdown_files)
208-
146+
"Plotter Utility": resource_path("utils/PlotterUtil_GUI.py"),
147+
"GPIB Scanner": resource_path("utils/GPIB_Instrument_Scanner_GUI.py"),
148+
"PICA Help": resource_path("README.md"),
149+
}
150+
151+
152+
def launch_pica_script(script_key):
153+
"""
154+
Globally accessible function to launch PICA scripts by their key.
155+
This uses the same resource_path and Process logic as PICALauncherApp
156+
to ensure consistency and correct path resolution for installed packages.
157+
"""
158+
if script_key not in PICALauncherApp.SCRIPT_PATHS:
159+
print(f"ERROR: Script key '{script_key}' not found in PICA SCRIPT_PATHS.")
160+
messagebox.showwarning(
161+
"Script Not Found",
162+
f"The script key '{script_key}' is not defined in the main application's script paths.")
163+
return
164+
165+
script_path = PICALauncherApp.SCRIPT_PATHS[script_key]
166+
print(f"Launching external script: {os.path.basename(script_path)}")
167+
abs_path = os.path.abspath(script_path)
168+
169+
if not os.path.exists(abs_path):
170+
print(f"ERROR: Script not found at {abs_path}")
171+
messagebox.showerror(
172+
"File Not Found",
173+
f"Script not found:\n\n{abs_path}")
174+
return
175+
176+
try:
177+
proc = Process(target=run_script_process, args=(abs_path,))
178+
proc.start()
179+
print(f"Successfully launched '{os.path.basename(script_path)}' in a new process.")
180+
except Exception as e:
181+
print(f"ERROR: Failed to launch script '{script_key}'. Reason: {e}")
182+
messagebox.showerror(
183+
"Launch Error",
184+
f"An error occurred while launching the script '{script_key}':\n\n{e}")
185+
186+
187+
class PICALauncherApp:
188+
189+
PROGRAM_VERSION = "1.0.0"
190+
CLR_BG_DARK = '#2B3D4F'
191+
CLR_FRAME_BG = '#3A506B'
192+
CLR_ACCENT_GOLD = '#FFC107'
193+
CLR_ACCENT_GREEN = '#A7C957'
194+
CLR_TEXT = '#EDF2F4'
195+
CLR_TEXT_DARK = '#1A1A1A'
196+
CLR_CONSOLE_BG = '#1E2B38'
197+
CLR_LINK = '#87CEEB' # Sky Blue, for better contrast
198+
FONT_SIZE_BASE = 12
199+
FONT_BASE = ('Segoe UI', FONT_SIZE_BASE)
200+
FONT_TITLE = ('Segoe UI', FONT_SIZE_BASE + 10, 'bold')
201+
FONT_SUBTITLE = ('Segoe UI', FONT_SIZE_BASE + 1, 'bold') # Reduced size from +2
202+
FONT_INSTITUTE = (
203+
'Segoe UI',
204+
FONT_SIZE_BASE + 6,
205+
'bold') # New font for institute
206+
FONT_CONSOLE = ('Consolas', 10)
207+
FONT_INFO = ('Segoe UI', FONT_SIZE_BASE)
208+
FONT_INFO_ITALIC = ('Segoe UI', FONT_SIZE_BASE, 'italic')
209+
LOGO_FILE = resource_path("assets/LOGO/UGC_DAE_CSR_NBG.jpeg")
210+
MANUAL_FILE = resource_path("docs/User_Manual.md")
211+
README_FILE = resource_path("README.md")
212+
LICENSE_FILE = resource_path("LICENSE")
213+
UPDATES_FILE = resource_path("CHANGELOG.md")
214+
REPO_URL = "https://github.com/prathameshnium/PICA-Python-Instrument-Control-and-Automation/tree/main"
215+
LOGO_SIZE = 140
209216
def setup_styles(self):
210217
style = ttk.Style(self.root)
211218
style.theme_use('clam')

0 commit comments

Comments
 (0)