Niklas R
Niklas R

Reputation: 16900

PyQT - How to implement Syntax Highlighting?

I want to write a little IDE for Cython using PyQT, but I don't have any idea how to implement Syntax Highlighting.
I know how to parse the Python-source, but I don't know how I can set the color for different words within the Textfield in PyQT.
I could use HTML for this, but how does it work in realtime ? I mean when the user edits the text I need to be able to immediately change the text's format, etc.

Do you know how I can achieve this ?

Upvotes: 1

Views: 1397

Answers (2)

Ed.
Ed.

Reputation: 449

I would recommend checking out the code in KhtEditor which is written in Python using PyQt. I believe the author is also working on a port from QWidget to QML.

Upvotes: 1

RichieHindle
RichieHindle

Reputation: 281835

Have you considered using QScintilla?

"As well as features found in standard text editing components, QScintilla includes features especially useful when editing and debugging source code. These include support for syntax styling, error indicators, code completion and call tips."

Upvotes: 5

Related Questions