@@ -143,10 +143,45 @@ 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- "PICA Help" : resource_path ("README.md" ),
148- }
149-
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 } " )
150185 def __init__ (self , root ):
151186 self .root = root
152187 self .root .title (f"PICA Launcher v{ self .PROGRAM_VERSION } " )
0 commit comments