Search code examples
linuxwxpythonrichtextboxwxwidgetstextctrl

Change the text color in a wx.TextCtrl under Mac or Linux


I am looking for a widget under wx that is similar to TextCtrl with the capabilities to show rich content under Linux and Mac (e.g. different text colors in different lines). I know that wx.TextCtrl with wx.TE_RICH style (or wx.RichTextCtrl) only works under Windows, and not under Mac and Linux.

I have also checked stc.StyledTextCtrl which seems to have the desired capability, given a schema for coloring, so it is mainly used for syntax highlighting. So, I doubt that it works.

So, I was wondering if there is a text box widget TB for wx with an API like:

TB.AppendText("Hello, this is Black", wx.BLACK)
TB.AppendText(" and this is Blue", wx.BLUE)

Any help is appreciated.


Solution

  • Um, what gave you that idea? The rich text flag for the wx.TextCtrl works fine on Linux for me. I'm using wxPython 2.8.12.0. You may have to use wx.TE_RICH2 though. I was testing using the wxPython demo to see if it worked and it does.

    The RichText control in wx.richtext also works as does the FancyText and StyleTextCtrls. I am testing on CentOS 6.