Domanda

I'm using wxpython to create GUI with python, now, is there a way to color specific part of the text?

Example (using Tkinter):

http://i.stack.imgur.com/fGAVA.png

Here is my Print function:

def Print(self, String):
    ''' Print Received Data '''

    self.text_serverLog.AppendText(datetime.now().strftime("[%H:%M:%S] " + String + "\n"))

I found the function SetForegroundColour but sadly its color the whole TextCtrl.

I'm using Win7, python 2.7, wxpython. Thanks.

È stato utile?

Soluzione

You can use the wx.TextCtrl in RichText mode by setting its style flag to wx.TE_RICH or wx.TE_RICH2. You can also use the aforementioned RichTextCtrl or the StyledTextCtrl (1 or 2). There's also FancyText, but I think that's more of a helper for drawing text than a real control the user can edit. Regardless, all of these widgets have examples in the wxPython demo package, which you can find at the wxPython website's download page.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top