Hi, I've tried searching around for other problems similar to mine, and I was unable to find any. I seem to not be able to "color" text in a TextCtrl widget on Windows, but I can on Linux. I have a little screenshot and some code to show this:




import wx

class MainWindow(wx.Frame):
    def __init__(self, parent, title, size_):
        wx.Frame.__init__(self, parent, title=title, size=size_)
        self.textArea = wx.TextCtrl(self, style=wx.TE_MULTILINE)
        self.textArea.AppendText("This text should be colored.")
    def colorText(self):
        self.textArea.SetStyle(5, 9, wx.TextAttr("#ff9c00", "#000000"))

app = wx.PySimpleApp()
frame = MainWindow(None, "Example", (400,300))

Is the SetStyle method not supported on Windows or what? Is there any way I could get around this problem? I think a while ago I read about being able to do this when you initiate the TextCtrl instance (line 8 of my code), by setting "style" equal to some special styling format, but I'm not positive about that.

Thanks in advance.

Sorry for resurrecting the old thread, but I thought I would post the solution to my problem. On line 8 of my code, I create a multiline TextCtrl widget to put my text in. On Linux, this is all that is needed in order to style text. However, in Windows, you must add the wx.TE_RICH2 attribute to a TextCtrl widget in order to do this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.