我在我的项目中实现了这个类:
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键时:它不会自动缩进。而且,也没有自动完成(但我甚至不知道它应该自动完成什么)。在
如有任何建议,我将不胜感激。在
这两个问题都是由于未能正确引用lexer而引起的。在
如果执行以下操作,示例代码将有效:
或者这个:
^{pr2}$相关问题 更多 >
编程相关推荐