def __init__(self, text, parent=None):
        super(ScriptEditorWidget, self).__init__(parent)

        font = QFont()
        font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(10)
        self.setFont(font)
        self.setMarginsFont(font)

        fontmetrics = QFontMetrics(font)
        self.setMarginsFont(font)
        self.setMarginWidth(0, fontmetrics.width("00000") + 6)
        self.setMarginLineNumbers(0, True)
        self.setMarginsBackgroundColor(QColor("#cccccc"))

        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QColor("#ffe4e4"))

        lexer = QsciLexerPython()
        lexer.setDefaultFont(font)
        self.setLexer(lexer)
        self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Courier')

        self.setText(text)
Esempio n. 2
0
    def __init__(self, parent=None):
        super(RevsetEntry, self).__init__(parent)
        self.setMarginWidth(1, 0)
        self.setReadOnly(False)
        self.setUtf8(True)
        self.setCaretWidth(10)
        self.setCaretLineBackgroundColor(QColor("#e6fff0"))
        self.setCaretLineVisible(True)
        self.setAutoIndent(True)
        self.setMatchedBraceBackgroundColor(Qt.yellow)
        self.setIndentationsUseTabs(False)
        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        self.setWrapMode(QsciScintilla.WrapWord)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

        sp = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
        sp.setHorizontalStretch(1)
        sp.setVerticalStretch(0)
        self.setSizePolicy(sp)

        self.setAutoCompletionThreshold(2)
        self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
        self.setAutoCompletionFillupsEnabled(True)
        self.setLexer(QsciLexerPython(self))
        self.lexer().setFont(qtlib.getfont('fontcomment').font())
        self.apis = QsciAPIs(self.lexer())
    def __init__(self, parent=None):
        FILENAME = 'generar_plantilla_ui.ui'
        QtGui.QMainWindow.__init__(self)
        uifile = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                              FILENAME)
        uic.loadUi(uifile, self)
        self.__centerOnScreen()
        self.setWindowState(QtCore.Qt.WindowMaximized)
        QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Escape), self,
                        self.close)
        # atrubutos e instancias
        self.logica = LogicaGenerarSenales()
        self.lm = LogicMethods()
        self.generar_en = ''
        self.nombre_ui = ''
        self.nombre_clase = ''
        self.nombre_widget = ''
        self.path_ui = ''

        self.arbolWidgets = TreeView(self.treeWidgets,
                                     self.on_arbolWidgets_selectedItem,
                                     self.connect)
        self.tablaMetodos = MyTableWidget(self.twMetodos, ['Metodo'])

        # llamada a metodos
        lexer = QsciLexerPython()
        self.qscArchivo.setLexer(lexer)
        self.__setScintillaProperties(self.qscArchivo)

        #self.logica.loadRecentFilesInCombo( self.cbArchivos )
        #self.cargarPlantilla()
        #self.cargarListaMetodos()
        self.setWindowTitle("Generar plantilla para un .ui")
    def __init__(self, parent=None):
        QsciScintilla.__init__(self, parent)

        # Set the default font
        font = QFont()
        font.setFamily(fontName)
        font.setFixedPitch(True)
        font.setPointSize(fontSize)
        fontmetrics = QFontMetrics(font)

        # Margin 0 is used for line numbers
        self.setMarginsFont(font)
        self.setMarginWidth(1, fontmetrics.width("00000"))
        self.setMarginLineNumbers(1, True)
        #self.setMarginsBackgroundColor(QColor("#cccccc"))

        # Brace matching: enable for a brace immediately before or after the current position
        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        # Current line visible with special background color
        self.setCaretLineVisible(True)
        #self.setCaretLineBackgroundColor(caretBackground)

        # Set Python lexer
        self.setLexer(QsciLexerPython())
        # override style settings to the same font and size
        # (python lexer has styles 0 ... 15)
        for i in range(16):
            self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, i, fontName)
            self.SendScintilla(QsciScintilla.SCI_STYLESETSIZE, i, fontSize)

        # make the source read-only
        self.SendScintilla(QsciScintilla.SCI_SETREADONLY, True)
Esempio n. 5
0
    def get_editor(self):
        """
        Return an editor object based on QScintilla if available.
        Else, return a standard editor.
        """

        try:
            from PyQt4.Qsci import QsciScintilla, QsciLexerPython, QsciAPIs
            
            textedit = QsciScintilla(self)
            textedit.setAutoIndent(True)
            textedit.setAutoCompletionThreshold(2)
            textedit.setAutoCompletionSource(QsciScintilla.AcsDocument)

            # API
            lex = QsciLexerPython(textedit)
            textedit.setLexer(lex)

#             apis = QsciAPIs(lex)
#             apis.prepare()
            
            textedit.setMinimumWidth(250)
            textedit.setMinimumHeight(250)
            
        except ImportError:
            textedit = qt.QtGui.QTextEdit(self)
            textedit.setLineWrapMode(qt.QtGui.QTextEdit.NoWrap)
            textedit.setMinimumWidth(200)
            textedit.setMinimumHeight(200)

        return textedit
Esempio n. 6
0
    def setLexers(self):
        self.lexer = QsciLexerPython()

        loadFont = self.settings.value("pythonConsole/fontfamilytext", "Monospace")
        fontSize = self.settings.value("pythonConsole/fontsize", 10, type=int)

        font = QFont(loadFont)
        font.setFixedPitch(True)
        font.setPointSize(fontSize)
        font.setStyleHint(QFont.TypeWriter)
        font.setStretch(QFont.SemiCondensed)
        font.setLetterSpacing(QFont.PercentageSpacing, 87.0)
        font.setBold(False)

        self.lexer.setDefaultFont(font)
        self.lexer.setColor(Qt.red, 1)
        self.lexer.setColor(Qt.darkGreen, 5)
        self.lexer.setColor(Qt.darkBlue, 15)
        self.lexer.setFont(font, 1)
        self.lexer.setFont(font, 3)
        self.lexer.setFont(font, 4)

        self.api = QsciAPIs(self.lexer)
        chekBoxAPI = self.settings.value("pythonConsole/preloadAPI", True, type=bool)
        if chekBoxAPI:
            self.api.loadPrepared( QgsApplication.pkgDataPath() + "/python/qsci_apis/pyqgis_master.pap" )
        else:
            apiPath = self.settings.value("pythonConsole/userAPI", [])
            for i in range(0, len(apiPath)):
                self.api.load(unicode(apiPath[i]))
            self.api.prepare()
            self.lexer.setAPIs(self.api)

        self.setLexer(self.lexer)
Esempio n. 7
0
 def setupEditor(self):
     editor = self.textEdit
     if QsciLexerPython:
         editor.setLexer(QsciLexerPython(editor))
         editor.setMarginLineNumbers(0, True)
         editor.setFolding(QsciScintilla.BoxedTreeFoldStyle)
         editor.setMarginWidth(0, '000')
     self.connect(editor, Signals.textChangedEditor, self,
                  Signals.textChangedEditor)
Esempio n. 8
0
    def setLexers(self):
        self.lexer = QsciLexerPython()

        loadFont = self.settings.value("pythonConsole/fontfamilytext",
                                       "Monospace")
        fontSize = self.settings.value("pythonConsole/fontsize", 10, type=int)

        font = QFont(loadFont)
        font.setFixedPitch(True)
        font.setPointSize(fontSize)
        font.setStyleHint(QFont.TypeWriter)
        font.setStretch(QFont.SemiCondensed)
        font.setLetterSpacing(QFont.PercentageSpacing, 87.0)
        font.setBold(False)

        self.lexer.setDefaultFont(font)
        self.lexer.setColor(Qt.red, 1)
        self.lexer.setColor(Qt.darkGreen, 5)
        self.lexer.setColor(Qt.darkBlue, 15)
        self.lexer.setFont(font, 1)
        self.lexer.setFont(font, 3)
        self.lexer.setFont(font, 4)

        self.api = QsciAPIs(self.lexer)
        chekBoxAPI = self.settings.value("pythonConsole/preloadAPI",
                                         True,
                                         type=bool)
        chekBoxPreparedAPI = self.settings.value(
            "pythonConsole/usePreparedAPIFile", False, type=bool)
        if chekBoxAPI:
            apisdir = os.path.join(QgsApplication.pkgDataPath(), "python",
                                   "qsci_apis")
            pap = os.path.join(apisdir, "pyqgis.pap")
            mpap = os.path.join(apisdir, "pyqgis-master.pap")
            if os.path.exists(
                    mpap):  # override installed with master .pap build
                pap = mpap
            if QgsApplication.isRunningFromBuildDir():
                bdir = os.path.dirname(QgsApplication.buildOutputPath())
                bpap = os.path.join(bdir, "python", "qsci_apis",
                                    "pyqgis-master.pap")
                if os.path.exists(bpap):
                    # if not generated .pap exists, else fall back to preprepared one
                    pap = bpap
            self.api.loadPrepared(pap)
        elif chekBoxPreparedAPI:
            self.api.loadPrepared(
                self.settings.value("pythonConsole/preparedAPIFile"))
        else:
            apiPath = self.settings.value("pythonConsole/userAPI", [])
            for i in range(0, len(apiPath)):
                self.api.load(unicode(apiPath[i]))
            self.api.prepare()
            self.lexer.setAPIs(self.api)

        self.setLexer(self.lexer)
Esempio n. 9
0
 def createWidget(self):
     """
     Create qt widget
     """
     self.setFolding(QsciScintilla.BoxedTreeFoldStyle)
     self.setLexer(QsciLexerPython(self))
     self.setMarginLineNumbers(0, False)
     self.setMarginWidth(1, 0)
     self.setTabWidth(2)
     self.setIndentationsUseTabs(True)
        def __init__(self, parent=None):
            QsciScintilla.__init__(self, parent)
            ## set the default font of the editor
            ## and take the same font for line numbers
            font = CurrentTheme.PYTHON_SOURCE_EDITOR_FONT
            self.setFont(font)
            fm = QtGui.QFontMetrics(font)

            ## Line numbers
            # conventionally, margin 0 is for line numbers
            self.setMarginWidth(0, fm.width("0000") + 4)
            self.setMarginLineNumbers(0, True)

            self.setAutoIndent(True)

            ## Edge Mode shows a red vetical bar at 80 chars
            self.setEdgeMode(QsciScintilla.EdgeLine)
            self.setEdgeColumn(80)
            self.setEdgeColor(QtGui.QColor("#CCCCCC"))

            ## Folding visual : we will use boxes
            self.setFolding(QsciScintilla.BoxedTreeFoldStyle)

            ## Braces matching
            self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

            ## Editing line color
            #    self.setCaretLineVisible(True)
            #    self.setCaretLineBackgroundColor(QtGui.QColor("#CDA869"))

            ## Margins colors
            # line numbers margin
            self.setMarginsBackgroundColor(QtGui.QColor("#FFFFFF"))
            self.setMarginsForegroundColor(QtGui.QColor("#000000"))

            # folding margin colors (foreground,background)
            self.setFoldMarginColors(QtGui.QColor("#DDDDDD"),
                                     QtGui.QColor("#DDDDDD"))
            # do not use tabs
            self.setIndentationsUseTabs(False)
            self.setTabWidth(4)
            self.setTabIndents(True)

            ## Choose a lexer
            lexer = QsciLexerPython()
            lexer.setDefaultFont(font)
            lexer.setFont(font)
            self.setLexer(lexer)

            # set autocompletion
            self.setAutoCompletionThreshold(2)
            self.setAutoCompletionSource(QsciScintilla.AcsDocument)
            self.setAutoCompletionCaseSensitivity(True)
            self.setAutoCompletionReplaceWord(True)
            self.setAutoCompletionFillupsEnabled(True)
Esempio n. 11
0
    def initLexer(self):
        if self.lexerType == self.LEXER_PYTHON:
            self.lexer = QsciLexerPython()

            colorDefault = QColor('#2e3436')
            colorComment = QColor('#c00')
            colorCommentBlock = QColor('#3465a4')
            colorNumber = QColor('#4e9a06')
            colorType = QColor('#4e9a06')
            colorKeyword = QColor('#204a87')
            colorString = QColor('#ce5c00')

            self.lexer.setDefaultFont(self.defaultFont)
            self.lexer.setDefaultColor(colorDefault)

            self.lexer.setColor(colorComment, 1)
            self.lexer.setColor(colorNumber, 2)
            self.lexer.setColor(colorString, 3)
            self.lexer.setColor(colorString, 4)
            self.lexer.setColor(colorKeyword, 5)
            self.lexer.setColor(colorString, 6)
            self.lexer.setColor(colorString, 7)
            self.lexer.setColor(colorType, 8)
            self.lexer.setColor(colorCommentBlock, 12)
            self.lexer.setColor(colorString, 15)

            self.lexer.setFont(self.italicFont, 1)
            self.lexer.setFont(self.boldFont, 5)
            self.lexer.setFont(self.boldFont, 8)
            self.lexer.setFont(self.italicFont, 12)

            self.api = QsciAPIs(self.lexer)

            settings = QSettings()
            useDefaultAPI = bool(
                settings.value('pythonConsole/preloadAPI', True))
            if useDefaultAPI:
                # Load QGIS API shipped with Python console
                self.api.loadPrepared(
                    os.path.join(QgsApplication.pkgDataPath(), 'python',
                                 'qsci_apis', 'pyqgis.pap'))
            else:
                # Load user-defined API files
                apiPaths = settings.value('pythonConsole/userAPI', [])
                for path in apiPaths:
                    self.api.load(path)
                self.api.prepare()
                self.lexer.setAPIs(self.api)
        elif self.lexerType == self.LEXER_R:
            # R lexer
            self.lexer = LexerR()

        self.setLexer(self.lexer)
Esempio n. 12
0
    def _load_code_editor_settings(self):
        """
        Load settings on the code editor like, font style, margins, scroll, etc.
        Based on the example from http://eli.thegreenplace.net/2011/04/01/sample-using-qscintilla-with-pyqt/
        """

        # Set the default font
        font = QFont()
        font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(14)
        self._code_editor.setFont(font)
        self._code_editor.setMarginsFont(font)

        # Margin 0 is used for line numbers
        fontmetrics = QFontMetrics(font)
        self._code_editor.setMarginsFont(font)
        self._code_editor.setMarginWidth(0, fontmetrics.width("00000") + 6)
        self._code_editor.setMarginLineNumbers(0, True)
        self._code_editor.setMarginsBackgroundColor(QColor("#cccccc"))

        # Clickable margin 1 for showing markers
        self._code_editor.setMarginSensitivity(1, True)
        self._code_editor.marginClicked.connect(self.on_margin_clicked)
        self._code_editor.markerDefine(QsciScintilla.RightArrow,
                                       self.ARROW_MARKER_NUM)
        self._code_editor.setMarkerBackgroundColor(QColor("#ee1111"),
                                                   self.ARROW_MARKER_NUM)

        # Detect changes to text
        self._code_editor.modificationChanged.connect(
            self.on_modification_changed)

        # Brace matching: enable for a brace immediately before or after the current position
        self._code_editor.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        # Current line visible with special background color
        self._code_editor.setCaretLineVisible(True)
        self._code_editor.setCaretLineBackgroundColor(QColor("#ffe4e4"))

        # Set Python lexer
        # Set style for Python comments (style number 1) to a fixed-width Courier.
        lexer = QsciLexerPython()
        lexer.setDefaultFont(font)
        self._code_editor.setLexer(lexer)
        # self._code_editor.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Courier')
        self._code_editor.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1)

        # Don't want to see the horizontal scrollbar at all
        # Use raw message to Scintilla here (all messages are documented here: http://www.scintilla.org/ScintillaDoc.html)
        self._code_editor.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)
Esempio n. 13
0
    def __init__(self, parent=None):
        super(SimplePythonEditor, self).__init__(parent)

        # Set the default font
        font = QFont()
        font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(10)
        self.setFont(font)
        self.setMarginsFont(font)

        # Margin 0 is used for line numbers
        fontmetrics = QFontMetrics(font)
        self.setMarginsFont(font)
        self.setMarginWidth(0, fontmetrics.width("00000") + 6)
        self.setMarginLineNumbers(0, True)
        self.setMarginsBackgroundColor(QColor("#cccccc"))

        # Clickable margin 1 for showing markers
        self.setMarginSensitivity(1, True)
        self.connect(self,
                     SIGNAL('marginClicked(int, int, Qt::KeyboardModifiers)'),
                     self.on_margin_clicked)
        self.markerDefine(QsciScintilla.RightArrow, self.ARROW_MARKER_NUM)
        self.setMarkerBackgroundColor(QColor("#ee1111"), self.ARROW_MARKER_NUM)

        # Brace matching: enable for a brace immediately before or after
        # the current position
        #
        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        # Current line visible with special background color
        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QColor("#ffe4e4"))

        # Set Python lexer
        # Set style for Python comments (style number 1) to a fixed-width
        # courier.
        #
        lexer = QsciLexerPython()
        lexer.setDefaultFont(font)
        self.setLexer(lexer)
        self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Courier')

        # Don't want to see the horizontal scrollbar at all
        # Use raw message to Scintilla here (all messages are documented
        # here: http://www.scintilla.org/ScintillaDoc.html)
        self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)

        # not too small
        self.setMinimumSize(600, 450)
Esempio n. 14
0
    def __init__(self, mainwindow):
        QsciScintilla.__init__(self, mainwindow)
        self.mainwindow = mainwindow
        ## define the font to use
        font = QFont()
        font.setFamily("Consolas")
        font.setFixedPitch(True)
        font.setPointSize(10)
        # the font metrics here will help
        # building the margin width later
        fm = QFontMetrics(font)

        ## set the default font of the editor
        ## and take the same font for line numbers
        self.setFont(font)
        self.setMarginsFont(font)

        ## Line numbers
        # conventionnaly, margin 0 is for line numbers
        self.setMarginWidth(0, fm.width( "00000" ) + 5)
        self.setMarginLineNumbers(0, True)

        ## Edge Mode shows a red vetical bar at 80 chars
        self.setEdgeMode(QsciScintilla.EdgeLine)
        self.setEdgeColumn(80)
        self.setEdgeColor(QColor("#CCCCCC"))

        ## Folding visual : we will use boxes
        self.setFolding(QsciScintilla.BoxedTreeFoldStyle)

        ## Braces matching
        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        ## Editing line color
        #self.setCaretLineVisible(True)
        #self.setCaretLineBackgroundColor(QColor("#CDA869"))

        ## Margins colors
        # line numbers margin
        self.setMarginsBackgroundColor(QColor("#333333"))
        self.setMarginsForegroundColor(QColor("#CCCCCC"))

        # folding margin colors (foreground,background)
        #self.setFoldMarginColors(QColor("#99CC66"),QColor("#333300"))
        self.setFoldMarginColors(QColor("#CCCCCC"),QColor("#CCCCCC"))

        ## Choose a lexer
        lexer = QsciLexerPython()
        lexer.setDefaultFont(font)
        self.setLexer(lexer)
Esempio n. 15
0
    def setLexers(self):
        self.lexer = QsciLexerPython()

        loadFont = self.settings.value("pythonConsole/fontfamilytext", "Monospace")
        fontSize = self.settings.value("pythonConsole/fontsize", 10, type=int)

        font = QFont(loadFont)
        font.setFixedPitch(True)
        font.setPointSize(fontSize)
        font.setStyleHint(QFont.TypeWriter)
        font.setStretch(QFont.SemiCondensed)
        font.setLetterSpacing(QFont.PercentageSpacing, 87.0)
        font.setBold(False)

        self.lexer.setDefaultFont(font)
        self.lexer.setDefaultColor(QColor(self.settings.value("pythonConsole/defaultFontColor", QColor(Qt.black))))
        self.lexer.setColor(QColor(self.settings.value("pythonConsole/commentFontColor", QColor(Qt.gray))), 1)
        self.lexer.setColor(QColor(self.settings.value("pythonConsole/keywordFontColor", QColor(Qt.darkGreen))), 5)
        self.lexer.setColor(QColor(self.settings.value("pythonConsole/classFontColor", QColor(Qt.blue))), 8)
        self.lexer.setColor(QColor(self.settings.value("pythonConsole/methodFontColor", QColor(Qt.darkGray))), 9)
        self.lexer.setColor(QColor(self.settings.value("pythonConsole/decorFontColor", QColor(Qt.darkBlue))), 15)
        self.lexer.setColor(QColor(self.settings.value("pythonConsole/commentBlockFontColor", QColor(Qt.gray))), 12)
        self.lexer.setColor(QColor(self.settings.value("pythonConsole/singleQuoteFontColor", QColor(Qt.blue))), 4)
        self.lexer.setColor(QColor(self.settings.value("pythonConsole/doubleQuoteFontColor", QColor(Qt.blue))), 3)
        self.lexer.setColor(QColor(self.settings.value("pythonConsole/tripleSingleQuoteFontColor", QColor(Qt.blue))), 6)
        self.lexer.setColor(QColor(self.settings.value("pythonConsole/tripleDoubleQuoteFontColor", QColor(Qt.blue))), 7)
        self.lexer.setFont(font, 1)
        self.lexer.setFont(font, 3)
        self.lexer.setFont(font, 4)

        for style in range(0, 33):
            paperColor = QColor(self.settings.value("pythonConsole/paperBackgroundColor", QColor(Qt.white)))
            self.lexer.setPaper(paperColor, style)

        self.api = QsciAPIs(self.lexer)
        chekBoxAPI = self.settings.value("pythonConsole/preloadAPI", True, type=bool)
        chekBoxPreparedAPI = self.settings.value("pythonConsole/usePreparedAPIFile", False, type=bool)
        if chekBoxAPI:
            pap = os.path.join(QgsApplication.pkgDataPath(), "python", "qsci_apis", "pyqgis.pap")
            self.api.loadPrepared(pap)
        elif chekBoxPreparedAPI:
            self.api.loadPrepared(self.settings.value("pythonConsole/preparedAPIFile"))
        else:
            apiPath = self.settings.value("pythonConsole/userAPI", [])
            for i in range(0, len(apiPath)):
                self.api.load(unicode(apiPath[i]))
            self.api.prepare()
            self.lexer.setAPIs(self.api)

        self.setLexer(self.lexer)
Esempio n. 16
0
 def setup_editor(self, editor):
     """Set various properties of a QScintilla widget.
     """
     # Brace matching: enable for a brace immediately before or after
     # the current position
     editor.setBraceMatching(QsciScintilla.SloppyBraceMatch)
     # Current line visible with special background color
     editor.setCaretLineVisible(True)
     editor.setCaretLineBackgroundColor(Qt.QColor("#ffe4e4"))
     # Make the cursor visible.
     editor.ensureCursorVisible()
     # Deal with indentation.
     editor.setAutoIndent(True)
     editor.setIndentationWidth(4)
     editor.setIndentationGuides(1)
     editor.setIndentationsUseTabs(0)
     editor.setAutoCompletionThreshold(2)
     editor.setBackspaceUnindents(True)
     # Deal with margins and breakpoint markers.
     editor.setMarginSensitivity(1, True)
     editor.connect(
         editor,
         Qt.SIGNAL('marginClicked(int, int, Qt::KeyboardModifiers)'),
         self.on_margin_clicked)
     editor.markerDefine(QsciScintilla.RightArrow,
                         StyleMixin.BREAK_MARKER_NUM)
     editor.setMarkerBackgroundColor(Qt.QColor("#0099FF"),
                                     StyleMixin.BREAK_MARKER_NUM)
     editor.setMarkerForegroundColor(Qt.QColor("#000000"),
                                     StyleMixin.BREAK_MARKER_NUM)
     editor.setFont(self.font)
     editor.setMarginsFont(self.font)
     # Mark the 79th column.
     editor.setEdgeColumn(79)
     editor.setEdgeMode(1)
     # Margin 0 is used for line numbers.
     fontmetrics = Qt.QFontMetrics(self.font)
     editor.setMarginsFont(self.font)
     editor.setMarginWidth(0, fontmetrics.width("00000") + 6)
     editor.setMarginLineNumbers(0, True)
     editor.setMarginsBackgroundColor(Qt.QColor("#cccccc"))
     # Set Python lexer and its fonts.
     lexer = QsciLexerPython()
     lexer.setDefaultFont(self.font)
     editor.setLexer(lexer)
     editor.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Courier')
     return
Esempio n. 17
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        self.setupUi(self)
        self.font = QtGui.QFont()
        self.setupui(self.textEdit, self.font)
        self.lexer = QsciLexerPython()

        self.textEdit.setLexer(self.lexer)
        self.textEdit.setText(r'''import MaxPlus
# Look in the MAXScript listener
MaxPlus.Core.WriteLine("hello world")''')

        self.btn_run.triggered.connect(self.editorrun)
        self.btn_clear.triggered.connect(self.editorclear)
        self.actionOpen.triggered.connect(self.loadfile)

        self.connect(self.tabWidget, QtCore.SIGNAL('tabCloseRequested(int)'),
                     self.closetab)
Esempio n. 18
0
    def setLexers(self):
        self.lexer = QsciLexerPython()

        settings = QSettings()
        loadFont = settings.value("pythonConsole/fontfamilytext",
                                  "Monospace").toString()
        fontSize = settings.value("pythonConsole/fontsize", 10).toInt()[0]
        font = QFont(loadFont)
        font.setFixedPitch(True)
        font.setPointSize(fontSize)

        self.lexer.setDefaultFont(font)
        self.lexer.setColor(Qt.red, 1)
        self.lexer.setColor(Qt.darkGreen, 5)
        self.lexer.setColor(Qt.darkBlue, 15)
        self.lexer.setFont(font, 1)
        self.lexer.setFont(font, 2)
        self.lexer.setFont(font, 3)
        self.lexer.setFont(font, 4)

        self.setLexer(self.lexer)
Esempio n. 19
0
 def createTab(self, py_de, ext, filename=""):
     newTabName = "tab" + str(self.centralwidget.count())
     newTextEditName = "textEdit" + str(self.centralwidget.count())
     print "createTab(): creating tab %s" % (newTabName)
     self.tab = QtGui.QWidget()
     self.tab.setObjectName(newTabName)
     self.tablayout = QtGui.QGridLayout(self.tab)
     self.centralwidget.addTab(self.tab,"")
     newTabIndex = self.centralwidget.indexOf(self.tab)
     if filename == "":
         filename = "Untitled" + str((newTabIndex + 1))
     newTabTitle = str(filename) + str(ext)
     self.centralwidget.setCurrentIndex(self.centralwidget.indexOf(self.tab))
     self.centralwidget.setTabText(newTabIndex, QtGui.QApplication.translate("py_de", newTabTitle, None, QtGui.QApplication.UnicodeUTF8))
     self.textEdit = QsciScintilla(self.tab)
     self.textEdit.setFont(self.font)
     self.textEdit.setMarginsFont(self.font)
     self.textEdit.setMarginWidth(0, self.fm.width( "00000" ) + 5)
     self.textEdit.setMarginLineNumbers(0, True)
     self.textEdit.setEdgeMode(QsciScintilla.EdgeLine)
     self.textEdit.setEdgeColumn(80)
     self.textEdit.setEdgeColor(QtGui.QColor("#FF0000"))
     self.textEdit.setFolding(QsciScintilla.BoxedTreeFoldStyle)
     self.textEdit.setBraceMatching(QsciScintilla.SloppyBraceMatch)
     self.textEdit.setCaretLineVisible(True)
     self.textEdit.setCaretLineBackgroundColor(QtGui.QColor("#CDA869"))
     self.textEdit.setMarginsBackgroundColor(QtGui.QColor("#333333"))
     self.textEdit.setMarginsForegroundColor(QtGui.QColor("#CCCCCC"))
     self.textEdit.setFoldMarginColors(QtGui.QColor("#99CC66"),QtGui.QColor("#333300"))
     lexer = QsciLexerPython()
     lexer.setDefaultFont(self.font)
     self.textEdit.setLexer(lexer)
     self.textEdit.show()
     sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Policy(1),QtGui.QSizePolicy.Policy(1))
     sizePolicy.setHorizontalStretch(0)
     sizePolicy.setVerticalStretch(0)
     sizePolicy.setHeightForWidth(self.textEdit.sizePolicy().hasHeightForWidth())
     self.textEdit.setSizePolicy(sizePolicy)
     self.textEdit.setObjectName(newTextEditName)
     self.tablayout.addWidget(self.textEdit, 0, 0, 1, 1)
Esempio n. 20
0
    def setLexers(self):
        self.lexer = QsciLexerPython()

        loadFont = self.settings.value("pythonConsole/fontfamilytext", "Monospace")
        fontSize = self.settings.value("pythonConsole/fontsize", 10, type=int)
        font = QFont(loadFont)
        font.setFixedPitch(True)
        font.setPointSize(fontSize)
        font.setStyleHint(QFont.TypeWriter)
        font.setStretch(QFont.SemiCondensed)
        font.setLetterSpacing(QFont.PercentageSpacing, 87.0)
        font.setBold(False)

        self.lexer.setDefaultFont(font)
        self.lexer.setColor(Qt.red, 1)
        self.lexer.setColor(Qt.darkGreen, 5)
        self.lexer.setColor(Qt.darkBlue, 15)
        self.lexer.setFont(font, 1)
        self.lexer.setFont(font, 2)
        self.lexer.setFont(font, 3)
        self.lexer.setFont(font, 4)

        self.setLexer(self.lexer)
    def __init__(self, iface):
        QDialog.__init__(self)
        self.iface = iface
        self.setupUi(self)
        self.path = standard_path()
        self.error = None
        self.matrices = {}

        self.but_load.clicked.connect(self.find_new_matrix)

        # MATH tab
        # Setting the advanced mode
        font = QFont()
        font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(12)
        lexer = QsciLexerPython()
        lexer.setDefaultFont(font)
        self.expression_box.setLexer(lexer)

        # toggling between modes
        self.rdo_basic_math.toggled.connect(self.toggle_basic_and_advanced)
        self.rdo_advanced_math.toggled.connect(self.toggle_basic_and_advanced)
        self.toggle_basic_and_advanced()
Esempio n. 22
0
 def setLexers(self, lexer):
     if lexer:
         font = QFont()
         font.setFamily('Mono')  ## Courier New
         font.setFixedPitch(True)
         ## check platform for font size
         if sys.platform.startswith('darwin'):
             font.setPointSize(13)
         else:
             font.setPointSize(10)
         self.setFont(font)
         self.setMarginsFont(font)
         self.lexer = QsciLexerPython()
         self.lexer.setDefaultFont(font)
         self.lexer.setColor(Qt.red, 1)
         self.lexer.setColor(Qt.darkGreen, 5)
         self.lexer.setColor(Qt.darkBlue, 15)
         self.lexer.setFont(font, 1)
         self.lexer.setFont(font, 3)
         self.lexer.setFont(font, 4)
         self.api = QsciAPIs(self.lexer)
         self.api.loadPrepared(
             QString(os.path.dirname(__file__) + "/api/pyqgis_master.pap"))
         self.setLexer(self.lexer)
Esempio n. 23
0
    def __init__(self, parent=None, cliptboard=None):
        FILENAME = 'generateSignals.ui'
        QtGui.QMainWindow.__init__(self)
        uifile = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                              FILENAME)
        uic.loadUi(uifile, self)
        self.__centerOnScreen()
        self.setWindowState(QtCore.Qt.WindowMaximized)
        QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Escape), self,
                        self.close)
        lexer = QsciLexerPython()
        self.qscArchivo.setLexer(lexer)
        self.qscSignals.setLexer(lexer)

        self.__setScintillaProperties(self.qscArchivo)
        self.__setScintillaProperties(self.qscSignals)

        self.logica = LogicaGenerarSenales()
        self.arbolWidgets = TreeView(self.treeWidgets,
                                     self.on_arbolWidgets_selectedItem,
                                     self.connect)
        self.arbolWidgets.widget.setAcceptDrops(True)
        self.cliptboard = cliptboard
        self.nombre_widget = ''
    def setLexers(self):
        self.lexer = QsciLexerPython()

        loadFont = self.settings.value("pythonConsole/fontfamilytext", "Monospace")
        fontSize = self.settings.value("pythonConsole/fontsize", 10, type=int)
        font = QFont(loadFont)
        font.setFixedPitch(True)
        font.setPointSize(fontSize)
        font.setStyleHint(QFont.TypeWriter)
        font.setStretch(QFont.SemiCondensed)
        font.setLetterSpacing(QFont.PercentageSpacing, 87.0)
        font.setBold(False)

        self.lexer.setDefaultFont(font)
        self.lexer.setDefaultColor(QColor(self.settings.value("pythonConsole/defaultFontColor", QColor(Qt.black))))
        self.lexer.setColor(QColor(self.settings.value("pythonConsole/commentFontColor", QColor(Qt.gray))), 1)
        self.lexer.setColor(QColor(self.settings.value("pythonConsole/keywordFontColor", QColor(Qt.darkGreen))), 5)
        self.lexer.setColor(QColor(self.settings.value("pythonConsole/classFontColor", QColor(Qt.blue))), 8)
        self.lexer.setColor(QColor(self.settings.value("pythonConsole/methodFontColor", QColor(Qt.darkGray))), 9)
        self.lexer.setColor(QColor(self.settings.value("pythonConsole/decorFontColor", QColor(Qt.darkBlue))), 15)
        self.lexer.setColor(QColor(self.settings.value("pythonConsole/commentBlockFontColor", QColor(Qt.gray))), 12)
        self.lexer.setColor(QColor(self.settings.value("pythonConsole/singleQuoteFontColor", QColor(Qt.blue))), 4)
        self.lexer.setColor(QColor(self.settings.value("pythonConsole/doubleQuoteFontColor", QColor(Qt.blue))), 3)
        self.lexer.setColor(QColor(self.settings.value("pythonConsole/tripleSingleQuoteFontColor", QColor(Qt.blue))), 6)
        self.lexer.setColor(QColor(self.settings.value("pythonConsole/tripleDoubleQuoteFontColor", QColor(Qt.blue))), 7)
        self.lexer.setColor(QColor(Qt.red), 14)
        self.lexer.setFont(font, 1)
        self.lexer.setFont(font, 2)
        self.lexer.setFont(font, 3)
        self.lexer.setFont(font, 4)

        for style in range(0, 33):
            paperColor = QColor(self.settings.value("pythonConsole/paperBackgroundColor", QColor(Qt.white)))
            self.lexer.setPaper(paperColor, style)

        self.setLexer(self.lexer)
Esempio n. 25
0
#        print "defaultPaper" + str( style ) + "=" + colorToString( lexer.defaultPaper( style ) )
#        print "defaultEolFill" + str( style ) + "=" + str( lexer.defaultEolFill( style ) )
#        print "defaultFont" + str( style ) + "=" + lexer.defaultFont( style ).toString()

        print "color" + str( style ) + "=" + colorToString( lexer.color( style ) )
        print "paper" + str( style ) + "=" + colorToString( lexer.paper( style ) )
        print "eolFill" + str( style ) + "=" + str( lexer.eolFill( style ) )
        print "font" + str( style ) + "=" + lexer.font( style ).toString()
        indexes.append( str( style ) )

    print "indexes=" + ",".join( indexes )
    print ""
    return


dumpLexer( QsciLexerPython() )
dumpLexer( QsciLexerBash() )
dumpLexer( QsciLexerBatch() )
dumpLexer( QsciLexerCMake() )
dumpLexer( QsciLexerCPP() )
dumpLexer( QsciLexerCSharp() )
dumpLexer( QsciLexerCSS() )
dumpLexer( QsciLexerDiff() )
dumpLexer( QsciLexerD() )
dumpLexer( QsciLexerFortran77() )
dumpLexer( QsciLexerFortran() )
dumpLexer( QsciLexerHTML() )
dumpLexer( QsciLexerIDL() )
dumpLexer( QsciLexerJava() )
dumpLexer( QsciLexerJavaScript() )
dumpLexer( QsciLexerLua() )
Esempio n. 26
0
    def initEditor(self):
        editor = QsciScintilla()

        ## define the font to use
        font = QtGui.QFont()
        #font.setFamily("Consolas")
        font.setFixedPitch(True)
        font.setPointSize(9)
        # the font metrics here will help
        # building the margin width later
        fm = QtGui.QFontMetrics(font)

        ## set the default font of the editor
        ## and take the same font for line numbers
        editor.setFont(font)
        editor.setMarginsFont(font)

        ## Line numbers
        # conventionnaly, margin 0 is for line numbers
        editor.setMarginWidth(0, fm.width("0000"))
        editor.setMarginLineNumbers(0, True)

        ## Edge Mode shows a red vetical bar at 80 chars
        editor.setEdgeMode(QsciScintilla.EdgeLine)
        editor.setEdgeColumn(80)
        editor.setEdgeColor(QtGui.QColor("#FF0000"))

        ## Folding visual : we will use boxes
        editor.setFolding(QsciScintilla.BoxedTreeFoldStyle)

        ## Braces matching
        editor.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        ## Editing line color
        editor.setCaretLineVisible(True)
        #editor.setCaretLineBackgroundColor(QtGui.QColor("#F5F5DC"))

        ## Margins colors
        # line numbers margin
        #editor.setMarginsBackgroundColor(QtGui.QColor("#333333"))
        #editor.setMarginsForegroundColor(QtGui.QColor("#CCCCCC"))

        # folding margin colors (foreground,background)
        #editor.setFoldMarginColors(QtGui.QColor("#99CC66"),QtGui.QColor("#333300"))

        ## Choose a lexer
        lexer = QsciLexerPython()
        lexer.setDefaultFont(font)
        editor.setLexer(lexer)

        ## Render on screen
        #editor.show()

        ## Show this file in the editor
        #editor.setText(open("examples\charriot_obj.txt").read())

        # Show all the methods of the editor
        #methods = sorted(QsciScintilla.__dict__.keys())
        #for m in methods :
        #    print m
        #editor.setWidth(400)

        editor.setEolMode(QsciScintilla.EolUnix)
        return editor
Esempio n. 27
0
            self._api.prepare()
        except Exception as err:
            self._api = None
            sys.exit(1)


if __name__ == '__main__':
    if len(sys.argv) != 4:
        print 'Usage: python <script> <pap_file> <apis_src_dir> <api_bin_dir>'
        sys.exit(1)
    pap_file = sys.argv[1]
    api_src_dir = sys.argv[2]
    api_bin_dir = sys.argv[3]

    api_files = [
        os.path.join(api_bin_dir, 'PyQGIS.api'),
        os.path.join(api_src_dir, 'Python-2.7.api'),
        os.path.join(api_src_dir, 'PyQt4-4.7.4.api'),
        os.path.join(api_src_dir, 'OSGeo_GEOS-3.4.2.api'),
        os.path.join(api_src_dir, 'OSGeo_GDAL-OGR-1.10.0.api')
    ]
    # print api_files.__repr__()
    # print pap_file.__repr__()

    app = QApplication(sys.argv, False)  # just start a non-gui console app
    api_lexer = QsciLexerPython()
    prepap = PrepareAPIs(api_lexer, api_files, pap_file)
    prepap.prepareAPI()

    sys.exit(app.exec_())
Esempio n. 28
0
    def __init__(self, _parent):
        MDialog.__init__(self, _parent)
        from PyQt4.Qsci import QsciScintilla, QsciLexerPython, QsciAPIs

        if isActivePyKDE4:
            self.setButtons(MDialog.NoDefault)
        self.sciCommand = QsciScintilla()
        self.sciCommand.setUtf8(True)
        self.sciCommand.setAutoIndent(True)
        self.sciCommand.setIndentationGuides(True)
        self.sciCommand.setIndentationsUseTabs(True)
        self.sciCommand.setCaretLineVisible(True)
        self.sciCommand.setAutoCompletionThreshold(2)
        self.sciCommand.setAutoCompletionSource(QsciScintilla.AcsDocument)
        self.sciCommand.setLexer(QsciLexerPython(self))
        self.sciCommand.setMarginLineNumbers(1, True)
        self.sciCommand.setMarginWidth(1, '0000')
        self.sciCommand.setEolMode(QsciScintilla.EolUnix)
        self.sciCommand.setWrapMode(QsciScintilla.WrapWord)
        lblScriptList = MLabel(translate("ScriptManager", "Script List : "))
        self.currentScriptFileName = None
        self.lwScriptList = Options.MyListWidget(self, [], _currentRowChanged=self.getFromScriptList)
        self.refreshScriptList()
        pbtnCreate = MPushButton(translate("ScriptManager", "Create"))
        pbtnDelete = MPushButton(translate("ScriptManager", "Delete"))
        pbtnSave = MPushButton(translate("ScriptManager", "Save"))
        pbtnScriptManagerAndClose = MPushButton(translate("ScriptManager", "Run And Close"))
        pbtnScriptManager = MPushButton(translate("ScriptManager", "Run"))
        pbtnClose = MPushButton(translate("ScriptManager", "Close"))
        pbtnClear = MPushButton(translate("ScriptManager", "Clear"))
        self.cckbIsAutoSaveScripts = Options.MyCheckBox(self, translate("ScriptManager", "Auto Save"), 2,
                                                        "isAutoSaveScripts")
        self.connect(pbtnCreate, SIGNAL("clicked()"), self.create)
        self.connect(pbtnDelete, SIGNAL("clicked()"), self.delete)
        self.connect(pbtnSave, SIGNAL("clicked()"), self.save)
        self.connect(pbtnScriptManagerAndClose, SIGNAL("clicked()"), self.runScriptAndClose)
        self.connect(pbtnScriptManager, SIGNAL("clicked()"), self.runScript)
        self.connect(pbtnClose, SIGNAL("clicked()"), self.close)
        self.connect(pbtnClear, SIGNAL("clicked()"), self.clear)
        pnlMain = MWidget(self)
        vblMain = MVBoxLayout(pnlMain)
        vbox = MVBoxLayout()
        vbox.addWidget(lblScriptList)
        vbox.addWidget(self.lwScriptList)
        hbox2 = MHBoxLayout()
        hbox2.addWidget(pbtnCreate)
        hbox2.addWidget(pbtnDelete)
        vbox.addLayout(hbox2)
        hbox0 = MHBoxLayout()
        hbox0.addLayout(vbox)
        hbox0.addWidget(self.sciCommand)
        hbox1 = MHBoxLayout()
        hbox1.addWidget(self.cckbIsAutoSaveScripts)
        hbox1.addStretch(1)
        hbox1.addWidget(pbtnClear, 1)
        hbox1.addWidget(pbtnSave, 1)
        hbox1.addWidget(pbtnScriptManager, 1)
        hbox1.addWidget(pbtnScriptManagerAndClose, 1)
        hbox1.addWidget(pbtnClose, 1)
        vblMain.addLayout(hbox0)
        vblMain.addLayout(hbox1)
        if isActivePyKDE4:
            self.setMainWidget(pnlMain)
        else:
            self.setLayout(vblMain)
        self.setWindowTitle(translate("ScriptManager", "Script Manager"))
        self.setWindowIcon(MIcon("Images:scriptManager.png"))
        self.lwScriptList.setMaximumWidth(150)
        self.setMinimumWidth(650)
        self.setMinimumHeight(450)
        self.show()
Esempio n. 29
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(640, 480)
        self.vindu = QtGui.QWidget(MainWindow)
        self.vindu.setStyleSheet(_fromUtf8('notusedasyet'))
        #MainWindow.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
        self.filename = ""
        self.vindu.setObjectName(_fromUtf8("vindu"))
        self.verticalLayout = QtGui.QVBoxLayout(self.vindu)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/ico/python.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
        MainWindow.setWindowIcon(icon)
        self.verticalLayout.setMargin(0)
        self.verticalLayout.setSpacing(0)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.codebox = Qsci.QsciScintilla(self.vindu)
        self.codebox.setToolTip(_fromUtf8(""))
        self.codebox.setWhatsThis(_fromUtf8(""))
        self.codebox.setAutoFillBackground(False)
        self.codebox.setFrameShape(QtGui.QFrame.NoFrame)
        self.codebox.setObjectName(_fromUtf8("codebox"))
        self.verticalLayout.addWidget(self.codebox)
        MainWindow.setCentralWidget(self.vindu)
        self.toolBar = QtGui.QToolBar(MainWindow)
        self.toolBar.setAutoFillBackground(False)
        self.toolBar.setIconSize(QtCore.QSize(32, 32))
        self.toolBar.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
        self.toolBar.setObjectName(_fromUtf8("toolBar"))
        MainWindow.addToolBar(QtCore.Qt.LeftToolBarArea, self.toolBar)
        self.toolBar.addSeparator()
        #first action Newfile
        self.toolBar.newAction = QtGui.QAction(QtGui.QIcon(":/ico/new.png"),"New",self.toolBar)
        self.toolBar.newAction.setStatusTip("Clear TextBox or make new document.")
        self.toolBar.newAction.setShortcut("Ctrl+N")
        self.toolBar.newAction.triggered.connect(self.newfile)
        #second Action OpenFile
        self.toolBar.secondAction = QtGui.QAction(QtGui.QIcon(":/ico/open.png"),"Open",self.toolBar)
        self.toolBar.secondAction.setStatusTip("Create a new document from scratch.")
        self.toolBar.secondAction.setShortcut("Ctrl+O")
        self.toolBar.secondAction.triggered.connect(self.open)
        # action 3 save file
        self.toolBar.Action3 = QtGui.QAction(QtGui.QIcon(":/ico/save.png"),"Save",self.toolBar)
        self.toolBar.Action3.setStatusTip("Save Your File.")
        self.toolBar.Action3.setShortcut("Ctrl+S")
        self.toolBar.Action3.triggered.connect(self.savefile)
        #action 4 run file
        self.toolBar.Action4 = QtGui.QAction(QtGui.QIcon(":/ico/run32.png"),"Run To Debugger",self.toolBar)
        self.toolBar.Action4.setStatusTip("Run your file within debugger.")
        self.toolBar.Action4.setShortcut("Ctrl+E")
        self.toolBar.Action4.triggered.connect(self.runto)
        #action 6 undo
        self.toolBar.Action6 =  QtGui.QAction(QtGui.QIcon(":/ico/undo.png"),"Redo",self.toolBar)
        self.toolBar.Action6.setStatusTip("Undo.")
        self.toolBar.Action6.setShortcut("Ctrl+Z")
        self.toolBar.Action6.triggered.connect(self.codebox.undo)
        #action 7 redo
        self.toolBar.Action7 = QtGui.QAction(QtGui.QIcon(":/ico/redo.png"),"Redo",self.toolBar)
        self.toolBar.Action7.setStatusTip("Redo.")
        self.toolBar.Action7.setShortcut("Ctrl+Y")
        self.toolBar.Action7.triggered.connect(self.codebox.redo)
        #action8 rerset Folding
        self.toolBar.Action8 = QtGui.QAction(QtGui.QIcon(":/ico/align-justify.png"),"Reset Folding",self.toolBar)
        self.toolBar.Action8.setStatusTip("Reset Folding.")
        self.toolBar.Action8.setShortcut("Ctrl+R")
        self.toolBar.Action8.triggered.connect(self.nofoldingl)
        #actions9 CircledTreeFoldStyle
        self.toolBar.Action9 = QtGui.QAction(QtGui.QIcon(":/ico/bullet.png"),"Circled Tree Folding",self.toolBar)
        self.toolBar.Action9.setStatusTip("Circled Tree Folding.")
        self.toolBar.Action9.setShortcut("Ctrl+C")
        self.toolBar.Action9.triggered.connect(self.Circledfold)
        #actions10 plainFoldStyle
        self.toolBar.Action10 = QtGui.QAction(QtGui.QIcon(":/ico/number.png"),"Plain Folding",self.toolBar)
        self.toolBar.Action10.setStatusTip("Plain Folding")
        self.toolBar.Action10.setShortcut("Ctrl+P")
        self.toolBar.Action10.triggered.connect(self.plainfold)
        #web baby
        self.toolBar.Action11 = QtGui.QAction(QtGui.QIcon(":/ico/web.png"),"Hex-rays Homepage",self.toolBar)
        self.toolBar.Action11.setStatusTip("Home of Hex-rays")
        self.toolBar.Action11.setShortcut("Ctrl+W")
        self.toolBar.Action11.triggered.connect(self.webopen)
        #irc
        self.toolBar.Action12 = QtGui.QAction(QtGui.QIcon(":/ico3/settings.png"),"Open Ida Pro Python SDK",self.toolBar)
        self.toolBar.Action12.setStatusTip("Ida Pro Python SDK")
        self.toolBar.Action12.setShortcut("Ctrl+I")
        self.toolBar.Action12.triggered.connect(self.sdkopen)
        #github Python
        self.toolBar.Action14 = QtGui.QAction(QtGui.QIcon(":/ico/github.png"),"Open git python",self.toolBar)
        self.toolBar.Action14.setStatusTip("Open git python")
        self.toolBar.Action14.setShortcut("Ctrl+G")
        self.toolBar.Action14.triggered.connect(self.gitopen)
        #auther me :)
        self.toolBar.Action15 = QtGui.QAction(QtGui.QIcon(":/ico/auth.png"),"Author",self.toolBar)
        self.toolBar.Action15.setStatusTip("Author")
        self.toolBar.Action15.setShortcut("Ctrl+B")
        self.toolBar.Action15.triggered.connect(self.Author)
        #toggle off code regonision
        self.toolBar.Action16 = QtGui.QAction(QtGui.QIcon(":/ico2/pythonminus.png"),"Disable Code recognition",self.toolBar)
        self.toolBar.Action16.setStatusTip("Disable Code recognition")
        self.toolBar.Action16.setShortcut("Alt+D")
        self.toolBar.Action16.triggered.connect(self.Diablecode)
        #toogle on
        self.toolBar.Action17 = QtGui.QAction(QtGui.QIcon(":/ico2/pypluss.png"),"Enable Code recognition",self.toolBar)
        self.toolBar.Action17.setStatusTip("Enable Code recognition")
        self.toolBar.Action17.setShortcut("Alt+E")
        self.toolBar.Action17.triggered.connect(self.Reiablecode)
        # zoom in
        self.toolBar.Action18 = QtGui.QAction(QtGui.QIcon(":/ico3/in.png"),"Zoom In",self.toolBar)
        self.toolBar.Action18.setStatusTip("Zoom In")
        self.toolBar.Action18.setShortcut("CTRL+SHIFT++")
        self.toolBar.Action18.triggered.connect(self.udder)
        #zoom out
        self.toolBar.Action19 = QtGui.QAction(QtGui.QIcon(":/ico3/out.png"),"Zoom Out",self.toolBar)
        self.toolBar.Action19.setStatusTip("Zoom Out")
        self.toolBar.Action19.setShortcut("CTRL+SHIFT+-")
        self.toolBar.Action19.triggered.connect(self.odder)

        self.toolBar.Action20 = QtGui.QAction(QtGui.QIcon(":/ico3/10.png"),"Profile Code",self.toolBar)
        self.toolBar.Action20.setStatusTip("Profile Code")
        self.toolBar.Action20.setShortcut("CTRL+SHIFT+E")
        self.toolBar.Action20.triggered.connect(self.runtoprob)

        #actions
        self.toolBar.addAction(self.toolBar.newAction)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.secondAction)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action3)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action4)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action6)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action7)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action8)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action9)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action10)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action11)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action12)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action14)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action15)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action16)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action17)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action18)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action19)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.toolBar.Action20)

        #font
        skrift = QFont()
        skrift.setFamily('Consolas')
        skrift.setFixedPitch(True)
        skrift.setPointSize(11)
        self.codebox.setFont(skrift)

        #python style
        lexer = QsciLexerPython(self.codebox)
        lexer.setEolFill(True)
        #api test not working
        api = Qsci.QsciAPIs(lexer)
        API_FILE = dn+'\\Python.api'
        API_FILE2 = dn+'\\idc.api'
        API_FILE3 = dn+'\\idaapi.api'
        api.load(API_FILE)
        api.load(API_FILE2)
        api.load(API_FILE3)

        api.prepare()
        self.codebox.setAutoCompletionThreshold(0)
        self.codebox.setAutoCompletionThreshold(6)
        self.codebox.setAutoCompletionThreshold(8)
        self.codebox.setAutoCompletionSource(Qsci.QsciScintilla.AcsAPIs)
        lexer.setDefaultFont(skrift)
        self.codebox.setLexer(lexer)
        self.codebox.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Consolas')

        #line numbers
        fontmetrics = QFontMetrics(skrift)
        self.codebox.setMarginsFont(skrift)
        self.codebox.setMarginWidth(0, fontmetrics.width("0000") + 6)
        self.codebox.setTabWidth(4)

        #brace
        self.codebox.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        #auto line tab =4
        self.codebox.setAutoIndent(True)

        #scroolbar
        self.codebox.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 1)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
Esempio n. 30
0
    def __init__(self, parent=None):
        super(SimplePythonEditorTextField, self).__init__(parent)

        # defaults
        self._filename = ''
        self._folder = ''
        self._changed = False
        self._parent = parent
        self._unsearched = True

        # Connect some actions
        self.textChanged.connect(self.on_textChanged)

        # disk file monitor
        self.fileWatcher = QtCore.QFileSystemWatcher()
        self.fileWatcher.fileChanged.connect(self.on_fileChanged)

        #
        # Setup the editor 
        #

        # Set the default font
        font = QtGui.QFont()
        font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(9.5)
        self.setFont(font)
        self.setMarginsFont(font)

        # Margin 0 is used for line numbers
        fontmetrics = QtGui.QFontMetrics(font)
        self.setMarginsFont(font)
        self.setMarginWidth(0, fontmetrics.width("0000") + 6)
        self.setMarginLineNumbers(0, True)
        self.setMarginsBackgroundColor(QtGui.QColor("#cccccc"))

        # Brace matching: enable for a brace immediately before or after
        # the current position
        #
        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        # Current line visible with special background color
        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QtGui.QColor("#ffe4e4"))

        # Unix end of line chars
        self.setEolMode(self.EolUnix)
        
        # Set Python lexer
        # Set style for Python comments (style number 1) to a fixed-width
        # courier.
        #
        lexer = QsciLexerPython()
        lexer.setDefaultFont(font)
        lexer.setFoldCompact(False) # so folding ends at the end of functions
                                    # not at the start of the next object
        self.setLexer(lexer)
        self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Courier')

        # unset control charaters I need access to

        commands = self.standardCommands()

        # free ctrl-L to goto line        
        command = commands.find(QsciCommand.LineCut)
        command.setKey(0)

        # Set python tabs
        self.setTabIndents(True)
        self.setTabWidth(4)
        self.setIndentationsUseTabs(False)

        #AutoIndentation
        self.setAutoIndent(True)
        self.setIndentationGuides(True)
        self.setIndentationWidth(4)

        # Code folding
        self.setMarginWidth(1, 14)
        self.setFolding(QsciScintilla.BoxedTreeFoldStyle)

        # Edge Mode shows a red vetical bar at 80 chars
        self.setEdgeMode(QsciScintilla.EdgeLine)
        self.setEdgeColumn(80)
        # self.setEdgeColor(QtGui.QColor("#FF0000"))

        # Don't want to see the horizontal scrollbar at all
        # Use raw message to Scintilla here (all messages are documented
        # here: http://www.scintilla.org/ScintillaDoc.html)
        self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 1)

        # not too small
        self.setMinimumSize(fontmetrics.averageCharWidth()*92, 450)