@@ -973,6 +973,37 @@ def saveopenfields(self, save_row, CCDplot):
973973 lambda * args : self .CCDplot .update_marker_colors (bool (self .element_match_var .get ())),
974974 )
975975
976+ # Tolerance settings for emission line matching
977+ tolerance_frame = ttk .Frame (self )
978+ tolerance_frame .grid (column = 0 , row = save_row + 6 , padx = (45 , 5 ), pady = (10 , 5 ), columnspan = 3 , sticky = "w" )
979+
980+ # Green tolerance (exact match)
981+ ttk .Label (tolerance_frame , text = "Green:" ).grid (row = 0 , column = 0 , padx = (0 , 2 ), sticky = "e" )
982+ self .green_tolerance_var = tk .DoubleVar (value = config .green_tolerance_nm )
983+ green_entry = ttk .Entry (tolerance_frame , textvariable = self .green_tolerance_var , width = 6 )
984+ green_entry .grid (row = 0 , column = 1 , padx = 2 )
985+ ttk .Label (tolerance_frame , text = "nm" ).grid (row = 0 , column = 2 , padx = (0 , 8 ), sticky = "w" )
986+
987+ # Yellow tolerance (close match)
988+ ttk .Label (tolerance_frame , text = "Yellow:" ).grid (row = 0 , column = 3 , padx = 2 , sticky = "e" )
989+ self .yellow_tolerance_var = tk .DoubleVar (value = config .yellow_tolerance_nm )
990+ yellow_entry = ttk .Entry (tolerance_frame , textvariable = self .yellow_tolerance_var , width = 6 )
991+ yellow_entry .grid (row = 0 , column = 4 , padx = 2 )
992+ ttk .Label (tolerance_frame , text = "nm" ).grid (row = 0 , column = 5 , padx = (0 , 8 ), sticky = "w" )
993+
994+ # Apply button in same row
995+ ttk .Button (
996+ tolerance_frame ,
997+ text = "Apply" ,
998+ command = self .apply_tolerance_settings ,
999+ style = "Accent.TButton"
1000+ ).grid (row = 0 , column = 6 , padx = 5 )
1001+
1002+ # Center the tolerance frame
1003+ self .grid_columnconfigure (0 , weight = 1 )
1004+ self .grid_columnconfigure (1 , weight = 1 )
1005+ self .grid_columnconfigure (2 , weight = 1 )
1006+
9761007 def open_calibration (self ):
9771008 """Open calibration window with proper callback reference"""
9781009 default_calibration .open_calibration_window (
@@ -1099,6 +1130,30 @@ def open_color_picker(self):
10991130 command = lambda : self .close_color_window ()
11001131 ).pack (pady = 15 )
11011132
1133+ def apply_tolerance_settings (self ):
1134+ """Apply the tolerance settings and refresh the plot"""
1135+ try :
1136+ green_val = self .green_tolerance_var .get ()
1137+ yellow_val = self .yellow_tolerance_var .get ()
1138+
1139+ # Validate inputs
1140+ if green_val <= 0 or yellow_val <= 0 :
1141+ return
1142+
1143+ if green_val >= yellow_val :
1144+ # Show warning that green should be less than yellow
1145+ return
1146+
1147+ # Update config values
1148+ config .green_tolerance_nm = green_val
1149+ config .yellow_tolerance_nm = yellow_val
1150+
1151+ # Refresh the plot to show updated colors
1152+ if config .spectroscopy_mode :
1153+ self .CCDplot .update_marker_colors (True )
1154+ except ValueError :
1155+ pass # Invalid number, ignore
1156+
11021157 def update_emission_color_controls (self ):
11031158 """Enable or disable emission line color controls based on current mode."""
11041159 button = getattr (self , "emission_color_button" , None )
@@ -1545,7 +1600,7 @@ def aboutbutton(self, about_row):
15451600
15461601 self .logo_label = ttk .Label (self , image = logo_photo )
15471602 self .logo_label .image = logo_photo # Keep a reference
1548- self .logo_label .grid (row = about_row + 1 , columnspan = 3 , pady = (40 , 5 ), padx = (7 ,0 ))
1603+ self .logo_label .grid (row = about_row + 1 , columnspan = 3 , pady = (15 , 5 ), padx = (7 ,0 ))
15491604 except Exception as e :
15501605 print (f"Could not load logo: { e } " )
15511606
0 commit comments