【发布时间】:2015-04-30 04:56:29
【问题描述】:
我在我的项目中实现了这个类:
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)
一切开始都很好,但是当我按下回车后:它只是不会自动缩进。而且,也没有自动完成(但我什至不知道它应该自动完成什么)。
如果有任何建议,我将不胜感激。
【问题讨论】:
标签: python qt pyqt qscintilla