george young wrote:

[python-2.2.1, gtk-2.1.1 pygtk-1.99.14, linux]
How can I change the grey background of an insensitive gtk.Entry?
I tried:
self.entry = gtk.Entry()
map=self.entry.get_colormap()
red=map.alloc('red')
style=self.entry.get_style().copy()
style.bg[gtk.STATE_INSENSITIVE] = red
self.entry.set_style(style)

from the FAQ, but it seemed to have no effect. Trying to set the foreground color
likewise had no effect...

I need the insensitive entry to be a much lighter grey (or the foreground to be
a full black) because it's too hard to read. This widget gets dynamically switched
between writable and read-only during the session. But even when read-only, it needs to
be easily and clearly readable. I could just manipulate 'editable', but then it still
accepts the focus and frustrates people who try to type at it.

Trying to change the default appearance like this can actually be harmful when you take theming into account. If you don't like the way the insensitive widgets are displayed, I suggest you try using another theme.

In your code above, consider what would happen if the text in insenstive widgets as red on black (as an example). Your code would reduce the readability even further (this is a fairly contrived example, but some of the accessibility themes are fairly different to the standard gtk theme and such a change could have a similar effect).

If you understand these problems, the way to fix your code is to set style.base rather than style.bg. The style colours fg/bg are used for user interface elements such as labels (usually black on grey). For things like entries (usually black on white), the colours text/base are used.

James.

--
Email: [EMAIL PROTECTED] | Linux.conf.au http://linux.conf.au/
WWW: http://www.daa.com.au/~james/ | Jan 22-25 Perth, Western Australia.


_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Reply via email to