Closed KenJean closed 5 years ago
Please use wx.GetBLACK()
/wx.GetLIGHT_GREY()
to get predefined colors.
To create a color, you can use wx.NewColour
Thanks so much for the quick response. I tried all sorts of other combinations (wx.ToColour, etc.) but hadn't come across what you've just taught me. Following your advice, I tried the following:
style := textctrl.GetDefaultStyle()
style.SetTextColour(wx.NewColour(wx.GetRED()))
textctrl.SetDefaultStyle(style)
textctrl.AppendText("Red text\n")
This code compiles and runs (yay !!!) but I do NOT get red text. I am on Arch Linux, by the way, in case that matters.
I've been combing through the source code without making much progress. I can sort it out when the wrapper functions follow the original wxWidgets/wxPython API closely, but once I hit all the Swig stuff, I get hopelessly lost trying to sort out what I'm supposed to do.
Thanks again. Any further ideas what I could be doing wrong?
⇒ KJ
Please have a try:
textCtrl.SetDefaultStyle(wx.NewTextAttrT(wx.GetRED()))
textCtrl.AppendText("Red text\n")
textCtrl.SetDefaultStyle(wx.NewTextAttrT(wx.NullColour, wx.GetLIGHT_GREY()))
textCtrl.AppendText("Red on grey text\n")
textCtrl.SetDefaultStyle(wx.NewTextAttrT(wx.GetBLUE()))
textCtrl.AppendText("Blue on grey text\n")
Yes !!!!!!! That works !!! I think I understand what I have to do now: I need to create a new TextAttr object whenever I need to change text attributes, rather than attempt to change an existing one.
Many, many thanks for teaching me how to do this. I shall mark this issue solved and closed
Trying to figure out how to do colour highlighting in TextCtrl.
For example:
wx.RED, wx.LIGHT_GREY and wx.BLUE do not exist in wxGo.
I understand the SetTextColour component does not take a wxColour argument and must take a SwigIsColour argument instead. How do I construct a SwigIsColour object ?? Everything I've found so far converts TO a wxColour object and not FROM a wxColour object.
Thanks in advance.
⇒ KJ