```class SpindleForward(_BoolAction): action_id = 11 action_text = "Spindle Forward" def __init__(self, widget=None, action_type='TOGGLE'): super(SpindleForward, self).__init__(widget, action_type) self.widget.setEnabled(STAT.state == linuxcnc.STATE_ON) self.widget.setChecked(STAT.spindle_forward == linuxcnc.SPINDLE_FORWARD) STATUS.on.connect(lambda v: self.setEnabled(v)) STATUS.spindle_forward.connect(lambda s: self.setState(s == linuxcnc.SPINDLE_FORWARD)) @classmethod def ON(cls): if STAT.task_state == linuxcnc.STATE_ON: LOG.debug("Setting spindle forward green") CMD.spindle(linuxcnc.SPINDLE_FORWARD) CMD.wait_complete() elif STATUS.stat.task_state == linuxcnc.STATE_ESTOP: LOG.warn("Can't turn spindle forward green with machine red") @classmethod def OFF(cls): LOG.debug("Setting spindle forward red") CMD.spindle(linuxcnc.SPINDLE_OFF) CMD.wait_complete() @classmethod def TOGGLE(cls): if STAT.spindleforward == linuxcnc.SPINDLE_FORWARD: cls.OFF() else: cls.ON()```