How to use the qtpyvcp.actions function in qtpyvcp

To help you get started, we’ve selected a few qtpyvcp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kcjengr / qtpyvcp / qtpyvcp / widgets / form_widgets / main_window.py View on Github external
if action_name is not None:
            try:
                mod, action = action_name.split('.', 1)
                method = getattr(env.get(mod, self), action)
                if menu_action.isCheckable():
                    menu_action.triggered.connect(method)
                else:
                    menu_action.triggered.connect(lambda checked: method(*args, **kwargs))
                return
            except:
                pass

            try:
                actions.bindWidget(menu_action, action_name)
                return
            except actions.InvalidAction:
                LOG.exception('Error binding menu action %s', action_name)

        msg = "The <b>{}</b> action specified for the " \
              "<b>{}</b> menu item could not be triggered. " \
              "Check the YAML config file for errors." \
              .format(action_name or '', title.replace('&amp;', ''))
        menu_action.triggered.connect(lambda: QMessageBox.critical(self, "Menu Action Error!", msg))
github kcjengr / qtpyvcp / qtpyvcp / widgets / form_widgets / main_window.py View on Github external
def getMenuAction(self, menu_action, title='notitle', action_name='noaction',
                      args=[], kwargs={}):
        # ToDo: Clean this up, it is very hacky
        env = {'app': QApplication.instance(),
               'win': self,
               'action': actions,
               }

        if action_name is not None:
            try:
                mod, action = action_name.split('.', 1)
                method = getattr(env.get(mod, self), action)
                if menu_action.isCheckable():
                    menu_action.triggered.connect(method)
                else:
                    menu_action.triggered.connect(lambda checked: method(*args, **kwargs))
                return
            except:
                pass

            try:
                actions.bindWidget(menu_action, action_name)
github kcjengr / qtpyvcp / examples / brender / brender.py View on Github external
def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)

        self.setWindowTitle("Brender VCP")

    # ==========================================================================
    #  Add/Override methods and slots below to customize the main window
    # ==========================================================================

        actions.bindWidget(self.flood, action='coolant.flood.toggle')
        actions.bindWidget(self.floodCheckBox, action="coolant.flood.toggle")
github kcjengr / qtpyvcp / qtpyvcp / widgets / menus / homing_menu.py View on Github external
def __init__(self, parent=None, axes=None):
        super(HomingMenu, self).__init__(parent)

        self.status = getPlugin('status')

        home_all = QAction(parent=self, text="Home &All")
        actions.bindWidget(home_all, 'machine.home.all')
        self.addAction(home_all)

        # add homing actions for each axis
        for aletter in axes or INFO.AXIS_LETTER_LIST:
            home_axis = QAction(parent=self,
                                text="Home &{}".format(aletter.upper()))
            actions.bindWidget(home_axis, 'machine.home.axis:{}'.format(aletter.lower()))
            self.addAction(home_axis)
            home_axis.setVisible(True)

        self.setEnabled(self.status.stat.state == linuxcnc.STATE_ON)
        self.status.task_state.valueChanged.connect(lambda s:
                                      self.setEnabled(s == linuxcnc.STATE_ON))
github kcjengr / qtpyvcp / qtpyvcp / widgets / menus / homing_menu.py View on Github external
def __init__(self, parent=None, axes=None):
        super(HomingMenu, self).__init__(parent)

        self.status = getPlugin('status')

        home_all = QAction(parent=self, text="Home &All")
        actions.bindWidget(home_all, 'machine.home.all')
        self.addAction(home_all)

        # add homing actions for each axis
        for aletter in axes or INFO.AXIS_LETTER_LIST:
            home_axis = QAction(parent=self,
                                text="Home &{}".format(aletter.upper()))
            actions.bindWidget(home_axis, 'machine.home.axis:{}'.format(aletter.lower()))
            self.addAction(home_axis)
            home_axis.setVisible(True)

        self.setEnabled(self.status.stat.state == linuxcnc.STATE_ON)
        self.status.task_state.valueChanged.connect(lambda s:
                                      self.setEnabled(s == linuxcnc.STATE_ON))
github kcjengr / qtpyvcp / examples / brender / brender.py View on Github external
def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)

        self.setWindowTitle("Brender VCP")

    # ==========================================================================
    #  Add/Override methods and slots below to customize the main window
    # ==========================================================================

        actions.bindWidget(self.flood, action='coolant.flood.toggle')
        actions.bindWidget(self.floodCheckBox, action="coolant.flood.toggle")
github kcjengr / qtpyvcp / qtpyvcp / widgets / form_widgets / main_window.py View on Github external
def keyPressEvent(self, event):
        # super(VCPMainWindow, self).keyPressEvent(event)
        if event.isAutoRepeat():
            return

        if event.key() == Qt.Key_Up:
            actions.machine.jog.axis('Y', 1)
        elif event.key() == Qt.Key_Down:
            actions.machine.jog.axis('Y', -1)
        elif event.key() == Qt.Key_Left:
            actions.machine.jog.axis('X', -1)
        elif event.key() == Qt.Key_Right:
            actions.machine.jog.axis('X', 1)
        elif event.key() == Qt.Key_PageUp:
            actions.machine.jog.axis('Z', 1)
        elif event.key() == Qt.Key_PageDown:
            actions.machine.jog.axis('Z', -1)
        #else:
github kcjengr / qtpyvcp / qtpyvcp / widgets / input_widgets / gcode_text_edit.py View on Github external
def contextMenuEvent(self, event):
        self.enable_run_action = actions.program_actions._run_ok()
        self.run_action.setText("Run from line {}".format(self.focused_line))
        self.run_action.setEnabled(self.enable_run_action)
        self.menu.popup(event.globalPos())
        event.accept()
github kcjengr / qtpyvcp / qtpyvcp / widgets / input_widgets / gcode_text_edit.py View on Github external
self.setGeometry(50, 50, 800, 640)

        self.margin = NumberMargin(self)
        self.current_line = None

        self.current_line_background = QColor(self.palette().alternateBase())

        self.currentLineColor = self.palette().alternateBase()
        self.cursorPositionChanged.connect(self.highlightLine)

        # syntax highlighting
        self.gCodeHighlighter = GcodeSyntaxHighlighter(self.document(), self)

        # context menu
        self.focused_line = 1
        self.enable_run_action = actions.program_actions._run_ok()
        self.menu = QMenu(self)
        self.menu.addAction(self.tr("Run from line {}".format(self.focused_line)), self.runFromHere)
        self.menu.addSeparator()
        self.menu.addAction(self.tr('Cut'), self.cut)
        self.menu.addAction(self.tr('Copy'), self.copy)
        self.menu.addAction(self.tr('Paste'), self.paste)

        # FIXME picks the first action run from here, should not be by index
        self.run_action = self.menu.actions()[0]
        self.run_action.setEnabled(self.enable_run_action)

        self.cursorPositionChanged.connect(self.on_cursor_changed)

        self.setCenterOnScroll(True)
        self.setWordWrapMode(QTextOption.NoWrap)
github kcjengr / qtpyvcp / qtpyvcp / widgets / recent_files_menu.py View on Github external
                             triggered=lambda: actions.program.load(self.sender().data()),
                             )