Beispiel #1
0
    def show(self, parent):
        self.editorParent = QtWidgets.QWidget(parent=parent)
        self.editorParent.setObjectName("ScriptEditor")
        self.splitter = QtWidgets.QSplitter(QtCore.Qt.Vertical)
        self.layout = qtutils.vBoxLayout(parent=self.editorParent)
        self.layout.addWidget(self.splitter)
        self.editor = pythoneditor.TabbedEditor(parent=parent)
        self.editor.setObjectName("Script Editor")
        self.editor.addNewEditor("New Tab")
        self.logout = logoutput.OutputLogDialog("History", parent=parent)

        self.pythonHighlighter = highlighter.highlighterFromJson(os.path.join(os.path.dirname(highlighter.__file__),
                                                                              "highlightdata.json"),
                                                                 self.logout.document())
        handler = logoutput.QWidgetHandler()
        handler.addWidget(self.logout)
        for logger in logging.Logger.manager.loggerDict.values():
            try:
                logger.addHandler(handler)
            except AttributeError:
                continue
        self.splitter.addWidget(self.logout)
        self.splitter.addWidget(self.editor)
        self.editor.outputText.connect(self.outputText)
        XStream.stdout().messageWritten.connect(self.logout.insertPlainText)
        XStream.stderr().messageWritten.connect(self.logout.logError)
        self.application.setShortcutForWidget(self.logout, "ScriptEditorHistory")
        self.application.setShortcutForWidget(self.editor, "ScriptEditor")

        return self.editorParent
Beispiel #2
0
        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"),
                        e).activated.connect(e.paste)
    QtWidgets.QShortcut(QtGui.QKeySequence("Ctrl+Shift+V"),
                        e).activated.connect(e.pasteAndSelect)
    QtWidgets.QShortcut(QtGui.QKeySequence("Ctrl+Z"),
                        e).activated.connect(e.undo)
    QtWidgets.QShortcut(QtGui.QKeySequence("Ctrl+Y"),
                        e).activated.connect(e.redo)

    e.setPlainText("foo(bar)\nfor bar in range(5):\n  print bar\n" +
                   "\nclass aap:\n  def monkey(self):\n    pass\n\n")

    # Run application
    e.show()
    s = QtWidgets.QSplitter()
    s.addWidget(e)
    s.addWidget(QtWidgets.QLabel("test"))
    s.show()
    app.exec_()