I have a multiline
wx.TextCtrl()
object which I set it’s forground and Background colors for writing strings.I need to write different lines with different colors ,
wx.TextCtrl.setForgroundcolor()
changes all previous lines colors as well.Is there a way around this?
There are several methods in wx.Python to get colored text.
wx.TextCtrlwithwx.TE_RICH,wx.TE_RICH2styleswx.stc.StyledTextCtrlwx.richtext.RichTextCtrlwx.HtmlWindow(inserting color tags in your text)wx.ListCrtlYou can get examples of all of them in the wxPython demo
For example, you can change fore and background colors in any part of a
wx.TextCrtl:wx.richtextis also easy to use to write lines with different colors:As indicated in other answer the use of a
wx.ListCrtlcan be a very straighforward method if you work with lines of text (instead of multiline text).