当前位置: 首页>>代码示例>>Python>>正文


Python Qsci.QsciAPIs类代码示例

本文整理汇总了Python中PyQt4.Qsci.QsciAPIs的典型用法代码示例。如果您正苦于以下问题:Python QsciAPIs类的具体用法?Python QsciAPIs怎么用?Python QsciAPIs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QsciAPIs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PrepareAPIDialog

class PrepareAPIDialog(QDialog):
    def __init__(self, api_lexer, api_files, pap_file, parent=None):
        QDialog.__init__(self, parent)
        self.ui = Ui_APIsDialogPythonConsole()
        self.ui.setupUi(self)
        self.setWindowTitle(QCoreApplication.translate("PythonConsole", "Compile APIs"))
        self.ui.plainTextEdit.setVisible(False)
        self.ui.textEdit_Qsci.setVisible(False)
        self.adjustSize()
        self._api = None
        self.ui.buttonBox.rejected.connect(self._stopPreparation)
        self._api_files = api_files
        self._api_lexer = api_lexer
        self._pap_file = pap_file

    def _clearLexer(self):
        # self.ui.textEdit_Qsci.setLexer(0)
        self.qlexer = None

    def _stopPreparation(self):
        if self._api is not None:
            self._api.cancelPreparation()
        self._api = None
        self._clearLexer()
        self.close()

    def _preparationFinished(self):
        self._clearLexer()
        if os.path.exists(self._pap_file):
            os.remove(self._pap_file)
        self.ui.label.setText(QCoreApplication.translate("PythonConsole", "Saving prepared file..."))
        prepd = self._api.savePrepared(unicode(self._pap_file))
        rslt = self.trUtf8("Error")
        if prepd:
            rslt = QCoreApplication.translate("PythonConsole", "Saved")
        self.ui.label.setText(u"{0} {1}".format(self.ui.label.text(), rslt))
        self._api = None
        self.ui.progressBar.setVisible(False)
        self.ui.buttonBox.button(QDialogButtonBox.Cancel).setText(QCoreApplication.translate("PythonConsole", "Done"))
        self.adjustSize()

    def prepareAPI(self):
        # self.ui.textEdit_Qsci.setLexer(0)
        exec(u"self.qlexer = {0}(self.ui.textEdit_Qsci)".format(self._api_lexer))
        # self.ui.textEdit_Qsci.setLexer(self.qlexer)
        self._api = QsciAPIs(self.qlexer)
        self._api.apiPreparationFinished.connect(self._preparationFinished)
        for api_file in self._api_files:
            self._api.load(unicode(api_file))
        try:
            self._api.prepare()
        except Exception as err:
            self._api = None
            self._clearLexer()
            self.ui.label.setText(QCoreApplication.translate("PythonConsole", "Error preparing file..."))
            self.ui.progressBar.setVisible(False)
            self.ui.plainTextEdit.setVisible(True)
            self.ui.plainTextEdit.insertPlainText(err)
            self.ui.buttonBox.button(QDialogButtonBox.Cancel).setText(self.trUtf8("Done"))
            self.adjustSize()
开发者ID:Geoneer,项目名称:QGIS,代码行数:60,代码来源:console_compile_apis.py

示例2: __init__

    def __init__(self, nombre_archivo, ext=''):
        super(Editor, self).__init__()
        self.__nombre = ""
        self.texto_modificado = False
        self.es_nuevo = True
        self.guardado_actualmente = False
        # Actualiza flags (espacios en blanco, cursor, sidebar, etc)
        self.actualizar()
        # Lexer
        self._lexer = None
        self.cargar_lexer(ext)
        # Autocompletado
        #FIXME:
        api = QsciAPIs(self._lexer)
        for palabra in keywords.keywords:
            api.add(palabra)
        api.prepare()
        self.setAutoCompletionThreshold(1)
        self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
        # Indentación
        self._indentacion = ESettings.get('editor/indentacionAncho')
        self.send("sci_settabwidth", self._indentacion)
        # Minimapa
        self.minimapa = MiniMapa(self)
        self.connect(self, SIGNAL("selectionChanged()"), self.minimapa.area)
        self.connect(self, SIGNAL("textChanged()"),
                     self.minimapa.actualizar_codigo)
        # Thread ocurrencias
        self.hilo_ocurrencias = ThreadBusqueda()
        self.connect(self.hilo_ocurrencias,
                     SIGNAL("ocurrenciasThread(PyQt_PyObject)"),
                     self.marcar_palabras)
        # Analizador de estilo de código
        self.checker = checker.Checker(self)
        self.connect(self.checker, SIGNAL("finished()"), self._show_violations)
        #self.checker.errores.connect(self._marcar_errores)
        # Fuente
        fuente = ESettings.get('editor/fuente')
        tam_fuente = ESettings.get('editor/fuenteTam')
        self.cargar_fuente(fuente, tam_fuente)
        self.setMarginsBackgroundColor(QColor(self._tema['sidebar-fondo']))
        self.setMarginsForegroundColor(QColor(self._tema['sidebar-fore']))

        # Línea actual, cursor
        self.caret_line(self._tema['caret-background'],
                        self._tema['caret-line'], self._tema['caret-opacidad'])
        # Márgen
        if ESettings.get('editor/margen'):
            self.actualizar_margen()

        # Brace matching
        self.match_braces(Base.SloppyBraceMatch)
        self.match_braces_color(self._tema['brace-background'],
                                self._tema['brace-foreground'])
        self.unmatch_braces_color(self._tema['brace-unbackground'],
                                  self._tema['brace-unforeground'])
开发者ID:ekimdev,项目名称:edis,代码行数:56,代码来源:editor.py

示例3: RevsetEntry

class RevsetEntry(QsciScintilla):

    returnPressed = pyqtSignal()

    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 addCompletions(self, *lists):
        for list in lists:
            for x, y in list:
                self.apis.add(x)
        self.apis.prepare()

    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape:
            event.ignore()
            return
        if event.key() in (Qt.Key_Enter, Qt.Key_Return):
            if not self.isListActive():
                event.ignore()
                self.returnPressed.emit()
                return
        super(RevsetEntry, self).keyPressEvent(event)

    def sizeHint(self):
        return QSize(10, self.fontMetrics().height())
开发者ID:velorientc,项目名称:git_test7,代码行数:52,代码来源:revset.py

示例4: __init__

    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())
开发者ID:velorientc,项目名称:git_test7,代码行数:28,代码来源:revset.py

示例5: setLexers

    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.setDefaultFont(QFont('Mono', 10, 0, False))
            # self.lexer.setDefaultColor(Qt.darkGray)
            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.api.load(os.path.dirname(__file__) + "/api/PyQGIS_1.8.api")
            #            self.api.load(os.path.dirname(__file__) + "/api/osgeo_gdal-ogr_1.9.1-1.api")
            #            self.api.load("qgis.networkanalysis.api")
            #            self.api.load("qgis.gui.api")
            #            self.api.load("qgis.core.api")
            #            self.api.load("qgis.analysis.api")

            #            self.api.prepare()
            #            self.lexer.setAPIs(self.api)
            self.setLexer(self.lexer)
开发者ID:rukku,项目名称:Quantum-GIS,代码行数:34,代码来源:console_sci.py

示例6: setup_api

 def setup_api(self):
     """Load and prepare Python API"""
     if self.lexer() is None:
         return
     self.api = QsciAPIs(self.lexer())
     is_api_ready = False
     api_path = CONF.get('editor', 'api')
     if not osp.isfile(api_path):
         from spyderlib.config import DATA_PATH
         api_path = osp.join(DATA_PATH, 'python.api')
         if osp.isfile(api_path):
             CONF.set('editor', 'api', api_path)
         else:
             return False
     api_size = CONF.get('editor', 'api_size', None)
     current_api_size = os.stat(api_path).st_size
     if api_size is not None and api_size == current_api_size:
         if self.api.isPrepared():
             is_api_ready = self.api.loadPrepared()
     else:
         CONF.set('editor', 'api_size', current_api_size)
     if not is_api_ready:
         if self.api.load(api_path):
             self.api.prepare()
             self.connect(self.api, SIGNAL("apiPreparationFinished()"),
                          self.api.savePrepared)
     return is_api_ready
开发者ID:cheesinglee,项目名称:spyder,代码行数:27,代码来源:qscieditor.py

示例7: init

 def init(self):
     self.setCaretLineBackgroundColor(self.colorStyle.caret)
     self.setMarginsBackgroundColor(self.colorStyle.margin)
     self.setMarkerBackgroundColor(self.colorStyle.marker,self.ARROW_MARKER_NUM)
     self.font = QFont()
     self.font.setFamily(fontName)
     #self.font.setFixedPitch(True)
     self.font.setPointSize(self.fontSize)
     self.setFont(self.font)
     self.fontmetrics = QFontMetrics(self.font)
     self.setMarginsFont(self.font)
     # Margin 0 is used for line numbers
     #self.setMarginLineNumbers(0, True)
     #self.setMarginWidth(0, self.fontmetrics.width("0000") + 6)
     self.setMarginLineNumbers(1, True)
     self.setMarginWidth(1, QString("-------"))
     self.setCaretLineVisible(True)
     if self.lang == 0:
         self.lexer = QsciLexerPython()
     elif self.lang == 1:
         self.lexer = QsciLexerCPP()
     elif self.lang == 2:
         self.lexer = LexerSquirrel(self.colorStyle,self)
     self.lexer.setDefaultFont(self.font)
     self.api = QsciAPIs(self.lexer)
     self.api.load(ospathjoin(apiDir,"emo.api"))
     self.api.prepare()
     self.lexer.setAPIs(self.api) #Very important do not change line otherwise gg
     self.setLexer(self.lexer) #Very important do not change line otherwise gg
开发者ID:dreadpiratepj,项目名称:Sabel,代码行数:29,代码来源:editor.py

示例8: active_code_completion

 def active_code_completion(self, enabled=True):
     if self.api is not None and enabled:
         return
     if enabled:
         self.api = QsciAPIs(self._lexer)
         if settings.get_setting('editor/completion-keywords'):
             for keyword in keywords.keywords:
                 self.api.add(keyword)
             self.api.prepare()
             source = QsciScintilla.AcsAPIs
             if settings.get_setting('editor/completion-document'):
                 source = QsciScintilla.AcsAll
         elif settings.get_setting('editor/completion-document'):
             source = QsciScintilla.AcsDocument
         else:
             source = QsciScintilla.AcsNone
         threshold = settings.get_setting('editor/completion-threshold')
         self.setAutoCompletionThreshold(threshold)
         self.setAutoCompletionSource(source)
         cs = settings.get_setting('editor/completion-cs')
         self.setAutoCompletionCaseSensitivity(cs)
         repl_word = settings.get_setting('editor/completion-replace-word')
         self.setAutoCompletionReplaceWord(repl_word)
         show_single = settings.get_setting('editor/completion-single')
         use_single = 2 if show_single else 0
         self.setAutoCompletionUseSingle(use_single)
     else:
         self.api = None
         self.setAutoCompletionSource(0)
开发者ID:Garjy,项目名称:edis,代码行数:29,代码来源:editor.py

示例9: setLexers

    def setLexers(self, lexer):
        from qgis.core import QgsApplication
        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( QgsApplication.pkgDataPath() + "/python/qsci_apis/pyqgis_master.pap" )

            self.setLexer(self.lexer)
开发者ID:mcmekuria,项目名称:Quantum-GIS,代码行数:25,代码来源:console_sci.py

示例10: setLexers

    def setLexers(self):
        self.lexer = QsciLexerPython()

        loadFont = self.settings.value("pythonConsole/fontfamilytext", "Monospace").toString()
        fontSize = self.settings.value("pythonConsole/fontsize", 10).toInt()[0]

        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).toBool()
        if chekBoxAPI:
            self.api.loadPrepared(QgsApplication.pkgDataPath() + "/python/qsci_apis/pyqgis_master.pap")
        else:
            apiPath = self.settings.value("pythonConsole/userAPI").toStringList()
            for i in range(0, len(apiPath)):
                self.api.load(QString(unicode(apiPath[i])))
            self.api.prepare()
            self.lexer.setAPIs(self.api)

        self.setLexer(self.lexer)
开发者ID:Arctictern265,项目名称:Quantum-GIS,代码行数:34,代码来源:console_sci.py

示例11: __init__

    def __init__(self, parent=None, line_num_margin=3, autocomplete_list=None):
        super(PythonEditor, self).__init__(parent, line_num_margin, autocomplete_list)

        # Set Python lexer
        self.lexer = QsciLexerPython(self)
        self.lexer.setDefaultFont(self.editor_font)
        self.lexer.setFont(self.editor_font, QsciLexerPython.Comment)
        # Indentation warning ("The indentation is inconsistent when compared to the previous line")
        self.lexer.setIndentationWarning(QsciLexerPython.Inconsistent)
        # Set auto-completion
        self.api = QsciAPIs(self.lexer)
        if autocomplete_list is not None:
            # Add additional completion strings
            for i in autocomplete_list:
                self.api.add(i)
        self.api.prepare()
        self.setAutoCompletionThreshold(3)
        self.setAutoCompletionSource(QsciScintilla.AcsAll)
        self.setAutoCompletionUseSingle(QsciScintilla.AcusExplicit)
        self.setLexer(self.lexer)

        # PEP8 tabs
        self.setIndentationsUseTabs(False)
        self.setAutoIndent(True)
        self.setIndentationGuides(True)
        
        # PEP8 edge column line
        self.edgecol = 80

        # Linters
        self.linter = 'internal'
开发者ID:akehrer,项目名称:fiddle,代码行数:31,代码来源:Editors.py

示例12: __init__

 def __init__(self, language, forPreparation = False, parent = None):
     """
     Constructor
     
     @param language language of the APIs object (string)
     @param forPreparation flag indicating this object is just needed
         for a preparation process (boolean)
     @param parent reference to the parent object (QObject)
     """
     QObject.__init__(self, parent)
     self.setObjectName("APIs_%s" % language)
     
     self.__inPreparation = False
     self.__language = language
     self.__forPreparation = forPreparation
     self.__lexer = Lexers.getLexer(self.__language)
     self.__apifiles = Preferences.getEditorAPI(self.__language)
     self.__apifiles.sort()
     if self.__lexer is None:
         self.__apis = None
     else:
         self.__apis = QsciAPIs(self.__lexer)
         self.connect(self.__apis, SIGNAL("apiPreparationFinished()"),
                      self.__apiPreparationFinished)
         self.connect(self.__apis, SIGNAL("apiPreparationCancelled()"),
                      self.__apiPreparationCancelled)
         self.connect(self.__apis, SIGNAL("apiPreparationStarted()"),
                      self.__apiPreparationStarted)
         self.__loadAPIs()
开发者ID:usc-bbdl,项目名称:R01_HSC_cadaver_system,代码行数:29,代码来源:APIsManager.py

示例13: CSSEditor

class CSSEditor(BaseEditor):
    def __init__(self, parent=None, line_num_margin=3, autocomplete_list=None):
        super(CSSEditor, self).__init__(parent, line_num_margin, autocomplete_list)

        # Set HTML lexer
        self.lexer = QsciLexerCSS(self)
        self.lexer.setDefaultFont(self.editor_font)
        # Set auto-completion
        self.api = QsciAPIs(self.lexer)
        if autocomplete_list is not None:
            # Add additional completion strings
            for i in autocomplete_list:
                self.api.add(i)
        self.api.prepare()
        self.setAutoCompletionThreshold(3)
        self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
        self.setLexer(self.lexer)
开发者ID:nmichaud,项目名称:fiddle,代码行数:17,代码来源:Editors.py

示例14: setApi

 def setApi(self, text):
     self.api = QsciAPIs(self.lexer)
     self.api.load(ospathjoin(apiDir,text+".api"))
     self.api.prepare()
     self.lexer.setAPIs(self.api) #Very important do not change line otherwise gg
     self.setLexer(self.lexer) #Very important do not change line otherwise gg
     editStyle = config.readStyle()
     self.setMarginsBackgroundColor(QColor(editStyle["margin"]))
     '''This is done cause the margin color is set only when lexer is set 
开发者ID:pyros2097,项目名称:SabelIDE,代码行数:9,代码来源:editor.py

示例15: prepareAPI

 def prepareAPI(self):
     try:
         self._api = QsciAPIs(self._api_lexer)
         self._api.apiPreparationFinished.connect(self._preparationFinished)
         for api_file in self._api_files:
             self._api.load(unicode(api_file))
         self._api.prepare()
     except Exception as err:
         self._api = None
         sys.exit(1)
开发者ID:Geoneer,项目名称:QGIS,代码行数:10,代码来源:generate_console_pap.py


注:本文中的PyQt4.Qsci.QsciAPIs类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。