Class hierarchy

1. The QScintilla package

When you install QScintilla for Python, it gets added to the PyQt5 package:

All the QScintilla classes are grouped in the PyQt5.QSci package. Let’s investigate them one by one.

2. QSciScintillaBase and QSciScintilla

The most fundamental class is QSciScintillaBase. It is the base class for text editing. As you can see in the figure below, this class inherits directly from the QAbstractScrollArea class in PyQt5. This is a pretty logic choice, isn’t it? Virtually every text editor is scrollable in some way.

The QSciScintillaBase class won’t be the class you will interact with directly. It is pretty low-level and therefore quite hard to use. QScintilla provides a high-level subclass: QSciScintilla. Your text editor will be an object from this class. It has a very Qt-like API, so Qt fans will feel at home. In some cases this high-level class might lack a very specific feature you need. That’s when you can call functions from the superclass QSciScintillaBase.


3. QSciLexer

The object you need for syntax highlighting is called a lexer. Once you’ve created and configured such a lexer object, you need to plug it into your text editor (which is an object from the QSciScintilla class). Huray, the code in your text editor gets all the colors of the rainbow!
But how do you make a lexer object? QScintilla provides the QSciLexer class for that purpose. The class itself is abstract, so you need to subclass it first before making an object:


4. QSciAPIs

A good text editor offers more than just syntax highlighting. Think about call tips and autocompletion for example. These features are present in the QSciAPIs class. You need to make an object from that class and plug it into your lexer object: