From 240dd8660eb578bf87d78a750c6dcc8c915380d3 Mon Sep 17 00:00:00 2001 From: Hans Unzner Date: Sat, 23 Nov 2024 21:56:30 +0100 Subject: [PATCH] gmoccapy: fix wrong states of spindle button images after program abort When a program with spindle on is aborted (assuming spindle off before program start), the images of the spindle buttons get a wrong state: the CSS property "-gtk-icon-effect" is set to "dim" which should be only set when they are disabled. Toggling the sensitive property twice corrects this wrong CSS property. --- src/emc/usr_intf/gmoccapy/gmoccapy.py | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/emc/usr_intf/gmoccapy/gmoccapy.py b/src/emc/usr_intf/gmoccapy/gmoccapy.py index 6f8e07b16e6..ae7195cca04 100644 --- a/src/emc/usr_intf/gmoccapy/gmoccapy.py +++ b/src/emc/usr_intf/gmoccapy/gmoccapy.py @@ -3985,7 +3985,10 @@ def on_rbt_forward_clicked(self, widget, data=None): widget.set_image(self.widgets.img_spindle_forward_on) self._set_spindle("forward") else: - self.widgets.rbt_forward.set_image(self.widgets.img_spindle_forward) + widget.set_image(self.widgets.img_spindle_forward) + # Toggling the sensitive property is important here! See the commit description. + widget.set_sensitive(not widget.get_sensitive()) + widget.set_sensitive(not widget.get_sensitive()) def on_rbt_reverse_clicked(self, widget, data=None): if widget.get_active(): @@ -3993,13 +3996,19 @@ def on_rbt_reverse_clicked(self, widget, data=None): self._set_spindle("reverse") else: widget.set_image(self.widgets.img_spindle_reverse) + # Toggling the sensitive property is important here! See the commit description. + widget.set_sensitive(not widget.get_sensitive()) + widget.set_sensitive(not widget.get_sensitive()) def on_rbt_stop_clicked(self, widget, data=None): if widget.get_active(): widget.set_image(self.widgets.img_spindle_stop_on) self._set_spindle("stop") else: - self.widgets.rbt_stop.set_image(self.widgets.img_spindle_stop) + widget.set_image(self.widgets.img_spindle_stop) + # Toggling the sensitive property is important here! See the commit description. + widget.set_sensitive(not widget.get_sensitive()) + widget.set_sensitive(not widget.get_sensitive()) def _set_spindle(self, command): # if we are in estop state, we will have to leave here, otherwise @@ -4012,18 +4021,6 @@ def _set_spindle(self, command): # be set to the commanded value due to the next code part if self.stat.task_mode != linuxcnc.MODE_MANUAL: if self.stat.interp_state == linuxcnc.INTERP_READING or self.stat.interp_state == linuxcnc.INTERP_WAITING: - if self.stat.spindle[0]['direction'] > 0: - self.widgets.rbt_forward.set_sensitive(False) - self.widgets.rbt_reverse.set_sensitive(True) - self.widgets.rbt_stop.set_sensitive(True) - elif self.stat.spindle[0]['direction'] < 0: - self.widgets.rbt_forward.set_sensitive(True) - self.widgets.rbt_reverse.set_sensitive(False) - self.widgets.rbt_stop.set_sensitive(True) - else: - self.widgets.rbt_forward.set_sensitive(True) - self.widgets.rbt_reverse.set_sensitive(True) - self.widgets.rbt_stop.set_sensitive(False) return rpm = self._check_spindle_range()