QScintilla problems.
Barry Scott <[email protected]>
| Newsgroups | gmane.comp.python.pyqt-pykde |
|---|---|
| Message-ID | <[email protected]> |
The attached code shows two problems with QScintilla. 1. SCI_STYLEGETFONT does not return the font. 2. Changing the size to 24pt makes line spacing be 24pt but the text is drawn in 11pt. (1) looks likes a bug. (2) may be that I do not understand something about how to drive the API. What makes Scintilla use the changed settings. (3) Changing the font does not seem to work either. What am I misunderstanding? Barry _______________________________________________ PyQt mailing list [email protected] https://www.riverbankcomputing.com/mailman/listinfo/pyqt
qsci_bug.py
(text/x-python-script, 1.8 KB)
#!/usr/bin/env python
import sys
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWidgets import QMainWindow, QLabel, QGridLayout, QWidget
from PyQt5.QtCore import QSize
from PyQt5 import Qsci
class HelloWindow(QMainWindow):
def __init__( self ):
super().__init__()
py_ver = '%d.%d' % (sys.version_info.major, sys.version_info.minor)
self.setMinimumSize( QSize(350, 100) )
self.setWindowTitle( 'GUI test - python %s' % (py_ver,) )
self.scin = Qsci.QsciScintilla( self )
self.scin.SendScintilla( self.scin.SCI_SETCODEPAGE, self.scin.SC_CP_UTF8 )
t = '''Example text line 1.
And this is line 2
'''
self.setCentralWidget( self.scin )
self.style_line_insert = self.scin.STYLE_LASTPREDEFINED + 1
res = self.scin.SendScintilla( self.scin.SCI_STYLEGETFONT, self.scin.STYLE_DEFAULT )
print( 'SCI_STYLEGETFONT res %r' % (res,) )
res = self.scin.SendScintilla( self.scin.SCI_STYLEGETSIZE, self.scin.STYLE_DEFAULT )
print( 'SCI_STYLEGETSIZE res %r' % (res,) )
print( 'SCI_STYLESETSIZE 24' )
res = self.scin.SendScintilla( self.scin.SCI_STYLESETSIZE, self.scin.STYLE_DEFAULT, 24 )
print( 'SCI_STYLESETSIZE res %r' % (res,) )
res = self.scin.SendScintilla( self.scin.SCI_STYLEGETSIZE, self.scin.STYLE_DEFAULT )
print( 'SCI_STYLEGETSIZE res %r' % (res,) )
font = b'Courier New'
print( 'SCI_STYLESETFONT %r' % (font,) )
res = self.scin.SendScintilla( self.scin.SCI_STYLESETFONT, self.scin.STYLE_DEFAULT, font )
print( 'SCI_STYLESETFONT res %r' % (res,) )
self.scin.SendScintilla( self.scin.SCI_INSERTTEXT, 0, t.encode( 'utf-8' ) )
if __name__ == "__main__":
app = QtWidgets.QApplication( sys.argv )
main_win = HelloWindow()
main_win.show()
sys.exit( app.exec_() )