1515import sys
1616import subprocess
1717import platform
18- import threading
19- import queue
2018import re
2119from datetime import datetime
2220import runpy
@@ -49,6 +47,8 @@ def run_script_process(script_path):
4947 """
5048 Wrapper function to execute a script using runpy in its own directory.
5149 This becomes the target for the new, isolated process.
50+ Note: os.chdir is acceptable here because this runs in a separate spawned process
51+ and does not affect the launcher's working directory.
5252 """
5353 try :
5454 os .chdir (os .path .dirname (script_path ))
@@ -190,6 +190,8 @@ def __init__(self, root):
190190 # Background tasks
191191 self ._pre_cache_markdown_files ()
192192 self .log (f"PICA Launcher initialized (v{ self .PROGRAM_VERSION } )" )
193+ # Auto-launch the GPIB/VISA scanner ~0.5 s after startup
194+ self .root .after (500 , self ._auto_launch_gpib )
193195
194196 def setup_styles (self ):
195197 style = ttk .Style (self .root )
@@ -352,8 +354,7 @@ def create_resource_panel(self, parent):
352354 util_frame ,
353355 text = "Plotter" ,
354356 style = 'App.TButton' ,
355- command = lambda : self .launch_script (
356- self .SCRIPT_PATHS ["Plotter Utility" ])).grid (
357+ command = launch_plotter_utility ).grid (
357358 row = 0 ,
358359 column = 1 ,
359360 sticky = 'ew' ,
@@ -474,11 +475,6 @@ def create_launcher_panel(self, parent):
474475 command = canvas .yview )
475476 scrollable_frame = ttk .Frame (canvas )
476477
477- scrollable_frame .bind (
478- "<Configure>" ,
479- lambda e : canvas .configure (scrollregion = canvas .bbox ("all" ))
480- )
481-
482478 def _on_mousewheel_windows (event ):
483479 canvas .yview_scroll (int (- 1 * (event .delta / 120 )), "units" )
484480
@@ -499,9 +495,8 @@ def _on_mousewheel_linux_macos(event):
499495 # --- Make the scrollable frame expand to the width of the canvas ---
500496 def _configure_scrollable_frame (event ):
501497 canvas .itemconfig ('frame' , width = event .width )
498+ canvas .configure (scrollregion = canvas .bbox ("all" ))
502499
503- canvas .create_window (
504- (0 , 0 ), window = scrollable_frame , anchor = "nw" , tags = "frame" )
505500 canvas .bind ("<Configure>" , _configure_scrollable_frame )
506501
507502 # --- Container for the two columns inside the scrollable frame ---
@@ -723,11 +718,6 @@ def open_script_folder(self, script_key):
723718 f"The script key '{ script_key } ' is not defined." )
724719 return
725720
726- # Special case for plotter utility which is in its own top-level folder
727- if script_key == "Plotter Utility" :
728- self ._open_path (os .path .dirname (os .path .abspath (script_path )))
729- return
730-
731721 folder_path = os .path .dirname (os .path .abspath (script_path ))
732722 if os .path .exists (folder_path ):
733723 self ._open_path (folder_path )
@@ -782,6 +772,11 @@ def run_gpib_test(self):
782772 return
783773 launch_gpib_scanner ()
784774
775+ def _auto_launch_gpib (self ):
776+ """Automatically opens the VISA/GPIB Utils module shortly after startup."""
777+ self .log ("Auto-launching VISA/GPIB Utils..." )
778+ self .run_gpib_test ()
779+
785780 def _pre_cache_markdown_files (self ):
786781 """
787782 Reads and parses key markdown/text files in the background.
0 commit comments