Ejemplo n.º 1
0
    def setShortcutForWidget(self, widget, name):
        keymap = self._keyBoardMapping.get(name)
        if not keymap:
            return

        for k, command in keymap:
            if command:
                QtWidgets.QShortcut(
                    QtGui.QKeySequence(k), widget,
                    partial(self.executeCommand, widget, command))
Ejemplo n.º 2
0
if __name__ == "__main__":

    app = QtWidgets.QApplication([])

    # Create editor instance
    e = CodeEditor(
        highlightCurrentLine=True,
        longLineIndicatorPosition=20,
        showIndentationGuides=True,
        showWhitespace=True,
        showLineEndings=True,
        wrap=True,
        showLineNumbers=True,
    )

    QtWidgets.QShortcut(QtGui.QKeySequence("F1"),
                        e).activated.connect(e.autocompleteShow)
    QtWidgets.QShortcut(QtGui.QKeySequence("F2"),
                        e).activated.connect(e.autocompleteCancel)
    QtWidgets.QShortcut(
        QtGui.QKeySequence("F3"),
        e).activated.connect(lambda: e.calltipShow(0, "test(foo, bar)"))
    QtWidgets.QShortcut(QtGui.QKeySequence("Shift+Tab"),
                        e).activated.connect(e.dedentSelection)  # Shift + Tab

    # TODO: somehow these shortcuts don't work in this test-app, but they do in
    # pyzo. May have something to do with overriding slots of Qt-native objects?
    QtWidgets.QShortcut(QtGui.QKeySequence("Ctrl+C"),
                        e).activated.connect(e.copy)
    QtWidgets.QShortcut(QtGui.QKeySequence("Ctrl+X"),
                        e).activated.connect(e.cut)
    QtWidgets.QShortcut(QtGui.QKeySequence("Ctrl+V"),