[PyQt] QtScintilla2 and fonts
kib2
kib2 at free.fr
Sat Jun 30 18:04:49 BST 2007
Phil Thompson a écrit :
>>
>> Can you please give me a sample ?
>
> There is a bug in readSettings() that is fixed in tonight's snapshot. Though I
> don't see how using the settings helps particularly. The eric source code is
> probably the best source of example code.
>
>> I've tried to see a edge line at column 80, but failed.
>> Here's the code :
>>
>> ## Edge Mode
>> editor.EdgeMode(QsciScintilla.EdgeLine)
>> editor.setEdgeColumn(80)
>> editor.setEdgeColor(QtGui.QColor("#FF0000"))
>
> You need to produce a short complete example that demonstrates the problem.
Hi Phil,
Here it is (name this file "qt4_sci_test.py"):
---->---->---->---->---->---->
#!/usr/bin/env python
# -*- coding: latin1 -*-
"""
A little try with the QScintilla2 widget
"""
import sys
from PyQt4.QtGui import QApplication
from PyQt4 import QtCore, QtGui
from PyQt4.Qsci import QsciScintilla, QsciScintillaBase,
QsciLexerPython, QsciLexerD
if __name__ == "__main__":
app = QApplication(sys.argv)
editor = QsciScintilla()
## define the font to use
font = QtGui.QFont()
font.setFamily("Consolas")
font.setFixedPitch(True)
font.setPointSize(10)
fm = QtGui.QFontMetrics(font)
## set the default font of the editor
editor.setFont(font)
editor.setMarginsFont(font)
editor.setMarginWidth(0, fm.width( "00000" ) + 5)
## Edge Mode : does not seems to work
editor.EdgeMode(QsciScintilla.EdgeLine)
editor.setEdgeColumn(80)
editor.setEdgeColor(QtGui.QColor("#FF0000"))
## Folding visual
editor.setFolding(QsciScintilla.BoxedTreeFoldStyle)
editor.setMarginLineNumbers(0, True)
## Braces matching
editor.setBraceMatching(QsciScintilla.SloppyBraceMatch)
## Paper background
# editor.setPaper(QtGui.QColor("#002008"))
## Editing line color
editor.setCaretLineVisible(True)
editor.setCaretLineBackgroundColor(QtGui.QColor("#CDA869"))
## Margins
# line numbers margin
editor.setMarginsBackgroundColor(QtGui.QColor("#333333"))
editor.setMarginsForegroundColor(QtGui.QColor("#CCCCCC"))
# folding margin colors (foreground,background)
editor.setFoldMarginColors(QtGui.QColor("#99CC66"),QtGui.QColor("#333300"))
## Choose a lexer
lexer = QsciLexerPython()
lexer.setDefaultFont(font)
editor.setLexer(lexer)
## Render on screen
editor.show()
## Show this file in the editor
editor.setText(open("qt4_sci_test.py").read())
sys.exit(app.exec_())
---->---->---->---->---->---->
More information about the PyQt
mailing list