Python Forum
[WxPython] How to change font color of SetHint or SetDescriptiveText?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[WxPython] How to change font color of SetHint or SetDescriptiveText?
#1
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.
Reply
#2
@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
Reply
#3
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.
Reply
#4
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
Reply
#5
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.
Reply
#6
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] [Solved]Change text color of one line in TextBrowser Extra 2 4,766 Aug-23-2022, 09:11 PM
Last Post: Extra
  Tkinter - How can I change the default Notebook border color? TurboC 5 14,638 May-23-2022, 03:44 PM
Last Post: bigmac
Question [Tkinter] Change Treeview column color? water 3 9,427 Mar-04-2022, 11:20 AM
Last Post: Larz60+
  Can't get tkinter button to change color based on changes in data dford 4 3,365 Feb-13-2022, 01:57 PM
Last Post: dford
  how to change font size barryjo 4 3,764 Jan-26-2022, 08:46 PM
Last Post: menator01
  Tkinter menu font size -method to change tonycat 2 7,710 Oct-11-2020, 02:43 AM
Last Post: tonycat
  [Tkinter] Trying to change font size w/o changing button size python63 3 9,739 Aug-05-2020, 01:04 AM
Last Post: Larz60+
  [tkinter] color change for hovering over button teacher 4 8,331 Jul-04-2020, 06:33 AM
Last Post: teacher
  [PyQt] Increase text size and change color based on temp pav1983 5 3,097 Jun-22-2020, 10:52 PM
Last Post: menator01
  TKINTER - Change font color for night or day Ayckinn 2 3,823 May-24-2020, 09:25 PM
Last Post: Ayckinn

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020