def closeEvent(self, event): if self.close_event: sound = None if self.PREFS_ and self.play_sounds and self.shutdown_play_sound: sound = self.shutdown_alert_sound_type answer = self.QTVCP_INSTANCE_.closeDialog_.showdialog( self.shutdown_msg_title, None, details=None, icon=MSG.CRITICAL, display_type='YESNO', focus_text='Close Linuxcnc?', focus_color=self._close_color, play_alert=sound) # system shutdown if answer == -1: if 'system_shutdown_request__' in dir(self.QTVCP_INSTANCE_): self.QTVCP_INSTANCE_.system_shutdown_request__() else: from qtvcp.core import Action ACTION = Action() ACTION.SHUT_SYSTEM_DOWN_PROMPT() event.accept() # close linuxcnc elif answer: if self.PREFS_ and self.play_sounds and self.shutdown_play_sound: STATUS.emit('play-sound', self.shutdown_exit_sound_type) event.accept() # cancel elif answer == False: event.ignore() return
def closeEvent(self, event): if self.close_event: sound = None if self.play_sounds and self.play_shutdown_sounds: sound = self.shutdown_alert_sound_type answer = self.QTVCP_INSTANCE_.closeDialog_.showdialog( self.shutdown_msg_title, None, details=None, icon=MSG.CRITICAL, display_type=MSG.YN_TYPE, focus_text='Close Linuxcnc?', focus_color=self._close_color, play_alert=sound) if answer == QtWidgets.QMessageBox.Yes: if self.play_sounds and self.play_shutdown_sounds: STATUS.emit('play-sound', self.shutdown_exit_sound_type) event.accept() elif answer == QtWidgets.QMessageBox.No: event.ignore() return elif answer == 0: from qtvcp.core import Action ACTION = Action() ACTION.SHUT_SYSTEM_DOWN_PROMPT() event.accept()
def closeEvent(self, event): if self.close_event: sound = None if self.PREFS_ and self.play_sounds and self.shutdown_play_sound: sound = self.shutdown_alert_sound_type try: if self.shutdown_msg_detail == '': details = None else: details = self.shutdown_msg_detail answer = self.QTVCP_INSTANCE_.closeDialog_.showdialog( self.shutdown_msg_title, None, details=details, icon=MSG.CRITICAL, display_type='YESNO', focus_text=self.shutdown_msg_focus_text, focus_color=self._close_color, play_alert=sound, use_exec=True) except: answer = True # system shutdown HANDLER = self.QTVCP_INSTANCE_.handler_instance if answer == QtWidgets.QMessageBox.DestructiveRole: if 'system_shutdown_request__' in dir(HANDLER): HANDLER.system_shutdown_request__() else: from qtvcp.core import Action ACTION = Action() ACTION.SHUT_SYSTEM_DOWN_PROMPT() if '_hal_cleanup' in dir(HANDLER): HANDLER._hal_cleanup() event.accept() # close linuxcnc elif answer: if self.PREFS_ and self.play_sounds and self.shutdown_play_sound: STATUS.emit('play-sound', self.shutdown_exit_sound_type) if '_hal_cleanup' in dir(HANDLER): HANDLER._hal_cleanup() event.accept() # cancel elif answer == False: event.ignore() return
#!/usr/bin/python3 from PyQt5 import QtCore, QtWidgets from qtvcp.widgets.widget_baseclass import _HalWidgetBase from qtvcp.core import Status, Action from qtvcp import logger # Instantiate the libraries with global reference # STATUS gives us status messages from linuxcnc # ACTION is for linuxcnc commands # LOG is for running code logging STATUS = Status() ACTION = Action() LOG = logger.getLogger(__name__) # Force the log level for this module #LOG.setLevel(logger.DEBUG) # One of DEBUG, INFO, WARNING, ERROR, CRITICAL class RadioAxisSelector(QtWidgets.QRadioButton, _HalWidgetBase): def __init__(self, parent=None): super(RadioAxisSelector, self).__init__(parent) self.toggled.connect(lambda:self.btnstate(self)) self.axis = '' self.joint = -1 def _hal_init(self): STATUS.connect('motion-mode-changed', lambda w,data: self.modeChanged(data)) def btnstate(self,b): if b.isChecked() == True:
if stderr != '': more = _("The error messages it produced are shown below:") else: more = None mess = {'NAME':'MESSAGE','ID':'ACTION_ERROR__', 'MESSAGE':message, 'MORE': more, 'DETAILS':stderr, 'ICON':'CRITICAL', 'FOCUS_TEXT': _('Filter program Error'), 'TITLE':'Program Filter Error'} STATUS.emit('dialog-request', mess) log.error('Filter Program Error:{}'.format (stderr)) # For testing purposes if __name__ == "__main__": from qtvcp.core import Action testcase = Action() # print status caught errors def mess(error,text): print('STATUS caught:',text) STATUS.connect("error", lambda w, n, d: mess(n,d)) # test case testcase.SAVE_PROGRAM('hi','/../../home')
# Set up logging from qtvcp import logger LOG = logger.getLogger(__name__) # Set the log level for this module #LOG.setLevel(logger.INFO) # One of DEBUG, INFO, WARNING, ERROR, CRITICAL ########################################### # **** INSTANTIATE LIBRARIES SECTION **** # ########################################### KEYBIND = Keylookup() STATUS = Status() INFO = Info() ACTION = Action( ) # http://linuxcnc.org/docs/2.8/html/gui/qtvcp_libraries.html#_action MSG = LcncDialog() ################################### # **** HANDLER CLASS SECTION **** # ################################### class HandlerClass: ######################## # **** INITIALIZE **** # ######################## # widgets allows access to widgets from the qtvcp files # at this point the widgets and hal pins are not instantiated def __init__(self, halcomp, widgets, paths): self.hal = halcomp