Hi, I'm trying to color some text with wxPython but I am having some trouble. I am using the SetStyle method of the TextCtrl widget. My problem is that the coloring works perfectly on Linux but does not under Windows.

My script basically gives a vocabulary test, and if you get a word correct, it should color the phrase "Correct!" green. Likewise, if you get it incorrect, "That is incorrect. Try again" should be colored red.

Rather than create a whole new example, I just attached my code in a .zip file. Just run wxVocabTest.py (only dependency is wxPython) and you will be able to see the problem.

So, why does it color fine in Linux but not Windows?

Thanks in advance.

Wow, dumb mistake on my part. I actually posted this exact same problem a few months ago. As I can see many people do not want to download my attached files, I provided a code example in my other thread.

Link:
http://www.daniweb.com/forums/thread275016.html

EDIT: Haha! I solved my own problem after some more research. So, I guess Windows and Linux differ in the fact that in order to change the style of text, Windows wants TextCtrl widgets to have the wx.TE_RICH2 attribute, while Linux does not need it. Quite strange.

The wxPython manual states:
Not all platforms support this function.

Be a part of the DaniWeb community

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