[QScintilla] QScintilla v2.9 QsciLexerCustom margin behaviour?
Matic Kukovec
matic.kukovec at pametnidom.si
Tue Apr 7 21:53:43 BST 2015
On 7.4.2015 21:58, Phil Thompson wrote:
> On 07/04/2015 8:18 pm, Matic Kukovec wrote:
>> On 5.4.2015 13:36, Phil Thompson wrote:
>>> On 04/04/2015 5:38 pm, Matic Kukovec wrote:
>>>> Hi Phil,
>>>>
>>>> The number margin background color turns white when applying a
>>>> QsciLexerCustom.
>>>> If the document is opened with a built-in lexer or without a lexer,
>>>> the number margin color is the default gray.
>>>>
>>>> Is this the correct behaviour? This didn't happen in the previous
>>>> version.
>>>
>>> Should be fixed in tonight's snapshot.
>>>
>>> Thanks,
>>> Phil
>>
>> Tried the last two snapshots and the number margin is still white on a
>> QsciLexerCustom.
>> Just to let you know.
>
> The change I made fixed it for me. Make sure you are really using the
> updated snapshot. If so send me a short, complete application that
> demonstrates the problem.
>
> Phil
Hey Phil,
Here is an example. You can switch lexers in lines 37/38. Line 37 has
the white margin.
I'm on Windows 7 64-bit using snapshot 'eb936ad1f826' with Python3.4
64-bit and PyQt4.11.3.
Oh, I just realized I should mention that I'm only compiling QScintilla,
not the entire PyQt4!
Compiled the source and just overwrote the 'qscintilla2.dll' in
'Python34\Lib\site-packages\PyQt4'.
Cheers,
Matic
-------------- next part --------------
import PyQt4.QtCore
import PyQt4.QtGui
import PyQt4.Qsci
import sys
import os
class Text(PyQt4.Qsci.QsciLexerCustom):
"""Lexer for styling normal text documents"""
#Class variables
default_color = PyQt4.QtGui.QColor(0, 0, 0)
default_font = PyQt4.QtGui.QFont('Courier', 10)
def __init__(self, parent=None):
"""Overridden initialization"""
#Initialize superclass
super().__init__()
self.setColor(self.default_color, 0)
self.setFont(self.default_font, 0)
def language(self):
return "Plain text"
def description(self, style):
return "Lexer for styling normal text documents"
def styleText(self, start, end):
self.startStyling(start)
self.setStyling(end - start, 0)
def main():
app = PyQt4.QtGui.QApplication(sys.argv)
wnd = PyQt4.QtGui.QMainWindow()
editor = PyQt4.Qsci.QsciScintilla(wnd)
editor.setLexer(Text())
# editor.setLexer(PyQt4.Qsci.QsciLexerPython())
editor.setUtf8(True)
editor.setMarginType(0, PyQt4.Qsci.QsciScintilla.NumberMargin)
editor.setMarginWidth(0, "00")
wnd.setCentralWidget(editor)
wnd.show()
sys.exit(app.exec_())
#Check if this is the main executing script
if __name__ == '__main__':
main()
More information about the QScintilla
mailing list