On Mon, 8 Oct 2001, Skip Montanaro wrote:
>
> How do I set the foreground color of a widget without using rc files or
> strings? I've tried this (w being a displayed gtk.Button instance in my
> example)
>
> gc = w.window.new_gc()
> color = gtk.gdk.color_parse("red")
> w.modify_fg(gtk.STATE_NORMAL, color)
>
> and
>
> gc = w.window.new_gc()
> color = gtk.gdk.color_parse("red")
> gc.set_foreground(color)
parse_color isn't enough. Basically, it just fills in the red, green and
blue members of of the GdkColor object. In order for the colour to be
usable, it needs to be allocated in the widget's GdkColormap.
Currently you can do this with "widget.get_colormap().alloc(colour)".
This will set the pixel member of the GdkColor, which is the index into
the widget's colormap (or for TrueColor visuals, just the packed
representation of the colour). This is what is really used by these
routines.
For 0.6.x, this process was all handled by the GdkColormap.alloc() method.
I haven't yet written the wrappers that would make GdkColormap.alloc in
1.99.x act this way as well.
James.
--
Email: [EMAIL PROTECTED]
WWW: http://www.daa.com.au/~james/
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk