O'Reilly logo

WxPython Application Development Cookbook by Cody Precord

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Styling text in StyledTextCtrl

The StyledTextCtrl class is an advanced text-editing component provided by the wx.stc module. This class is a wx wrapper around the Scintilla code editor control. This control is primarily geared toward editing source code files. It provides a large set of features for enhanced code-editing support. In this recipe, we will look at how to set up syntax highlighting for Python source code files using StyledTextCtrl.

How to do it…

Perform the following steps:

  1. This recipe will be split into two classes. Starting here with a base class to set up some programming language-independent settings on StyledTextCtrl. Take a look at the following code:
    import wx import wx.stc as stc import keyword class CodeEditorBase(stc.StyledTextCtrl): ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required