def _get_python_path():

    root_fld = (QgsApplication.buildOutputPath()
                if QgsApplication.isRunningFromBuildDir() else
                QgsApplication.pkgDataPath())

    return os.path.abspath(os.path.join(root_fld, 'python', 'plugins'))
示例#2
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)
示例#3
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)