[wxPython-users] textctrl with coloured background
Robin Dunn
robin at alldunn.com
Sat Nov 4 22:06:44 PST 2006
Christian Kristukat wrote:
> Hi,
> I am trying to set the background coulour of a textctrl. Neither of the
> following methods works (linux, wxPython 2.6.3.3):
>
> 1) SetBackgroundColour, followed by Refresh(True)
> 2) SetStyle(0,-1,TextAttr(wx.RED,wx.BLACK))
> 3) subclassing and binding to PAINT/ERASE events, the handlers are never called
>
> Basically I want to have a TextCtrl with optical feedback for the validity of
> the input, i.e. if the input is not acceptable, the background colour should
> turn to red, while still allowing the user to enter everything (in contrast to
> using a Validator). Has someone maybe done that already?
Most likely your gtk theme is blocking the ability to change the
background color. Some allow it, some don't. In the past some people
have gotten around this limitation by having a border around the
control[1] and changing the color of it.
[1] Either by drawing it on the parent, or by putting the control in
another panel that is sized a couple pixels larger than the control, and
then changing the bg color of that panel when needed.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list