Skip to content

Commit

Permalink
gmoccapy: fix wrong states of spindle button images after program abort
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hansu committed Nov 23, 2024
1 parent 061b4ea commit 240dd86
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/emc/usr_intf/gmoccapy/gmoccapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3985,21 +3985,30 @@ 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():
widget.set_image(self.widgets.img_spindle_reverse_on)
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
Expand All @@ -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()
Expand Down

0 comments on commit 240dd86

Please sign in to comment.