Python Forum
[WxPython] How to change font color of SetHint or SetDescriptiveText? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [WxPython] How to change font color of SetHint or SetDescriptiveText? (/thread-19212.html)



How to change font color of SetHint or SetDescriptiveText? - anistorian - Jun-18-2019

Hello!

I am trying to make a search field with a hint inside with wxPython, but I can't seem to figure out how to change the colour of the hint. If I add a 'SetForegroundColour' the text I type in changes colour, but that doesn't really help. I also fiddled around with 'SetDefaultStyle' and 'wx.TextAttr' for some hours now, but can't figure out where to put them, if that is indeed what I should be doing. Also tried adding styles to the arguments of SearchCtrl like 'wx.TEXT_ATTR_TEXT_COLOUR', but nothing has worked.

query_field = wx.SearchCtrl(panel, pos=(10,10), size=(200,25))
query_field.SetBackgroundColour("black")
query_field.SetDescriptiveText("#example")
query_field.ShowSearchButton(False)
I have made the background black so I can see that there actually is text inside the field, because when I change the background to white, it is completely invisible.

So if anyone could point me in the right direction, it would be really great.

Thank you.


RE: How to change font color of SetHint or SetDescriptiveText? - Denni - Jun-18-2019

@anistorian as a pointer going forward should you post another question -- denoting clearly what you are using within the subject or via a tag is very helpful to those of us that might be able to lend you a hand as there are several different flavors or GUIs being serviced within this forum

Not knowing wxPython, excuse me if this unnecessary, I would still think that clearly prefixing your question with what python version you are using as well as what wxPython version you are using might also prove of great assistance to someone trying to help you.

Good luck in getting your wxPython answer


RE: How to change font color of SetHint or SetDescriptiveText? - anistorian - Jun-18-2019

Hi Denni, I will surely keep that in mind! Thought it would be enough to write that I used wxPython within the post. But for anyone who might be able to help, I run macOS 10.14.5, python 3.7 and wxPython 4.0.6.

Thank you for the advice.


RE: How to change font color of SetHint or SetDescriptiveText? - jefsummers - Jun-18-2019

I could try to translate this, but I am relatively new myself. Try using the RichToolTip, and you may need to set the foreground color in the wx.font. See RichToolTip description for wxPython


RE: How to change font color of SetHint or SetDescriptiveText? - anistorian - Jun-19-2019

Hi! Thank you for your reply, but I think I found the problem. Even though it might not be a solution. Since the searchctrl utilizes a native widget, I don't think it is possible to change the font colour, since it is defined by my OS theme.


RE: How to change font color of SetHint or SetDescriptiveText? - Yoriz - Jun-19-2019

I expect that to be the case, i put a post up on google groups 'wxpython-users' on your behalf but have had no reply's yet.