Using wxStyledTextCtrl


First, here's where you will find documentation:

Also look at wxStyledTextCtrl.


Here is some misc. notes from RichardPrescott

Here's an example how to find the area to be styled:

   1 def onStyleNeeded(self, e):
   2     start = self.GetEndStyled()    # this is the first character that needs styling
   3     end = e.GetPosition()          # this is the last character that needs styling
   4     self.StartStyling(start, 31)   # in this example, only style the text style bits
   5     for pos in range(start, end):  # in this example, simply loop over it..
   6         self.SetStyling(1, NUMBER) # ..and set it all to the NUMBER style

Text modification

Here is some misc. notes from Francesco

* You can control what types of modifications will fire a EVT_STC_MODIFIED event with the SetModEventMask command.

Not documented in Stc Documentation at:

* CopyRange(4, 8) #copies text from pos1 (4) until pos2 (8) into clipboard

* CopyText(4, "abcd") #copies text ("abcd") into clipboard

X11 clipboard

There is a long standing bug in the wxPython code which prevents the X11 clipboard (middle mouse copy/paste) from working with STC controls. You can paste into them, but never can paste out of them. Even if you use wx.TheClipboard.UsePrimary() - it will have no effect at all in wxPython. C++ code using the STC is not affected by this and it works properly.

Normal copy/paste (using the second X11 clipboard) is not affected by this and works fine, i.e. you can use ctrl-C/ctrl-V to copy/paste between STC and other apps.

See here:

The above link is a bug filed by Robin Dunn himself several years ago.. and apparently still open. Oh well.

This is fixed as of (at least) 2.8.4.

StyledTextCtrl (last edited 2008-03-11 10:50:29 by localhost)

NOTE: To edit pages in this wiki you must be a member of the TrustedEditorsGroup.