首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Qscintilla2 AutoCompletion和AutoIdentation

Qscintilla2 AutoCompletion和AutoIdentation
EN

Stack Overflow用户
提问于 2015-02-27 21:01:26
回答 1查看 531关注 0票数 0

我在我的项目中实现了这个类:

代码语言:javascript
复制
class ScriptEditorTextBox(QsciScintilla):

def __init__(self, parent):
    QsciScintilla.__init__(self)

    #Lexer
    lexer = QsciLexerPython()

    #AutoCompletion
    api = Qsci.QsciAPIs(lexer)
    api.add('aLongString')
    api.add('aLongerString')
    api.add('aDifferentString')
    api.add('sOmethingElse')
    api.prepare()

    self.setLexer(lexer)
    self.setAutoCompletionThreshold(1)
    self.setAutoCompletionSource(QsciScintilla.AcsAPIs)

    #LineHighlight
    self.setCaretLineVisible(True)
    self.setCaretLineBackgroundColor(QColor("gainsboro"))

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

    #Margins
    self.setMarginsBackgroundColor(QColor("gainsboro"))
    self.setMarginsFont(QFont("Consolas", 9, 87)) 
    self.setMarginLineNumbers(1, True)
    self.setMarginLineNumbers(2, False)
    self.setMarginWidth(1, QString().setNum(10))
    self.setMarginWidth(2, 10)
    self.connect(self, SIGNAL("linesChanged()"), self._linesChanged)

def _linesChanged(self):
    width = QString().setNum(self.lines() * 10)
    self.setMarginWidth(1, width)

一切开始都很好,但是当我按enter键之后:它就不会自动缩进。而且,也没有自动补全(但我甚至不知道应该自动补全什么)。

如果有任何建议,我将不胜感激。

EN

回答 1

Stack Overflow用户

发布于 2015-02-28 05:47:31

这两个问题都是由于未能正确引用词法分析器而导致的。

如果执行以下操作,示例代码将正常工作:

代码语言:javascript
复制
    lexer = QsciLexerPython(self)

或者这样:

代码语言:javascript
复制
    self.lexer = QsciLexerPython()
    ...
    api = Qsci.QsciAPIs(self.lexer)
    ...
    self.setLexer(self.lexer)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28765761

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档