@@ -199,6 +199,7 @@ def __init__(self, argv):
199199 self .distance = 0 # This global will hold the jog distance
200200 self .tool_change = False # this is needed to get back to manual mode after a tool change
201201 self .load_tool = False # We use this avoid mode switching on reloading the tool on start up of the GUI
202+ self .apply_tool_changes = False # We use this avoid mode switching on automatic G43 during Aplly tooltable
202203 self .macrobuttons = [] # The list of all macros defined in the INI file
203204 self .fo_counts = 0 # need to calculate difference in counts to change the feed override slider
204205 self .so_counts = 0 # need to calculate difference in counts to change the spindle override slider
@@ -2776,6 +2777,10 @@ def on_hal_status_limits_tripped(self, object, state, lst_limits):
27762777 self .widgets .chk_ignore_limits .set_active (False )
27772778
27782779 def on_hal_status_mode_manual (self , widget ):
2780+ if self .apply_tool_changes :
2781+ LOG .debug ("switch to Manual page is ignored, because automatic G43 is running during Apply tooltable" )
2782+ return
2783+
27792784 LOG .debug ("MANUAL Mode" )
27802785 self .widgets .rbt_manual .set_active (True )
27812786 # if setup page is activated, we must leave here, otherwise the pages will be reset
@@ -2798,6 +2803,10 @@ def on_hal_status_mode_manual(self, widget):
27982803 self .last_key_event = None , 0
27992804
28002805 def on_hal_status_mode_mdi (self , widget ):
2806+ if self .apply_tool_changes :
2807+ LOG .debug ("switch to MDI page is ignored, because automatic G43 is running during Apply tooltable" )
2808+ return
2809+
28012810 LOG .debug ("MDI Mode, tool_change = {0}" .format (self .tool_change ))
28022811
28032812 # if the edit offsets button is active, we do not want to change
@@ -5064,9 +5073,32 @@ def on_btn_reload_tooltable_clicked(self, widget, data=None):
50645073 self .widgets .tooledit1 .set_selected_tool (self .stat .tool_in_spindle )
50655074
50665075 def on_btn_apply_tool_changes_clicked (self , widget , data = None ):
5076+ self .apply_tool_changes = True # Disable switch pages
5077+
50675078 self .widgets .tooledit1 .save (None )
50685079 self .widgets .tooledit1 .set_selected_tool (self .stat .tool_in_spindle )
50695080
5081+ # Automatic G43
5082+ if "G43" in self .active_gcodes :
5083+ self .command .wait_complete ()
5084+ self .command .mode (linuxcnc .MODE_MDI )
5085+ self .command .wait_complete ()
5086+ self .command .mdi ("G43" )
5087+ self .command .wait_complete ()
5088+ self .command .mode (linuxcnc .MODE_MANUAL )
5089+ self .command .wait_complete ()
5090+
5091+ # GUI update
5092+ self .stat .poll ()
5093+ toolinfo = self .widgets .tooledit1 .get_toolinfo (self .stat .tool_in_spindle )
5094+ if toolinfo :
5095+ self .widgets .lbl_tool_no .set_text (str (toolinfo [1 ]))
5096+ self .widgets .lbl_tool_dia .set_text (toolinfo [12 ])
5097+ self .halcomp ["tool-diameter" ] = float (locale .atof (toolinfo [12 ]))
5098+ self .widgets .lbl_tool_name .set_text (toolinfo [16 ])
5099+
5100+ self .apply_tool_changes = False # Disable switch pages
5101+
50705102 def on_btn_tool_touchoff_clicked (self , widget , data = None ):
50715103 if not self .widgets .tooledit1 .get_selected_tool ():
50725104 message = _ ("No or multiple tools selected in the tool table. " )
0 commit comments