As you can see in the gdk documentation[1]:

  �The GdkGCValues structure holds a set of values used to create or
modify a graphics context.

GdkColor foreground;
the foreground color. Note that
gdk_gc_get_values() only sets the
pixel value.
GdkColor background;
the background color. Note that
gdk_gc_get_values() only sets the
pixel value.�

  The note "Note that gdk_gc_get_values() only sets the pixel value."
appears to be missing from the PyGTK documentation.  Feel free about
filing a bug report regarding documentation.

  You can use gtk.gdk.Colormap.query_color to get the RGB values from
the pixel value.

  Regards.

[1]
http://developer.gnome.org/doc/API/2.0/gdk/gdk-Graphics-Contexts.html#GdkGCValues

On Fri, 2005-05-06 at 16:15 -0500, Brian Campbell wrote:
> Does anybody know how to get the rgb values from a gtk.gdk.GC?
> Attempting to access the values returns garbage, as evidenced by this
> example:
> 
> Python 2.4 (#1, Mar  9 2005, 09:57:26) [C] on irix6
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import pygtk
> >>> pygtk.require('2.0')
> >>> import gtk
> >>> widget = gtk.Window()
> >>> widget.show()
> >>> style = widget.get_style()
> >>> gc = style.fg_gc[gtk.STATE_NORMAL]
> >>> gc.foreground
> <GdkColor at 0x10327ce0>
> >>> gc.foreground.red
> 4107
> >>> gc.foreground.green
> 30416
> >>> gc.foreground.blue
> 0
> >>> colormap = widget.get_colormap()
> >>> red = colormap.alloc_color(0xFFFF, 0x00, 0x00)
> >>> red.red
> 65535
> >>> red.green
> 0
> >>> red.blue
> 0
> >>> gc.foreground = red
> >>> gc.foreground.red
> 4107
> >>> gc.foreground.green
> 30416
> >>> gc.foreground.blue
> 0
> 
> The color in the gc draws correctly to the screen.  I need the rgb values to
> match gtk colors with rendering done by other code.
> 
> 
> _______________________________________________
> pygtk mailing list   [email protected]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
-- 
Gustavo J. A. M. Carneiro
<[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
The universe is always one step beyond logic

_______________________________________________
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