[pygtk] drawing in an RGB color

John Hunter jdhunter@ace.bsd.uchicago.edu
Thu, 17 Oct 2002 15:07:43 -0500


I have a function draw_arcs that draws black, unfilled arcs.  I would
like to be able to draw in a specific rgb color, ideally using a
fraction in the range [0,1] to specify the RGB intensities.

I am having trouble setting the color, and cannot figure out how to
get a GdkGC.  description.py says "GdkGC's are created with the
GdkWindow.new_gc method" but I do not know what to make of this since when
I do dir(gtk.GtkWindow) I do not see anything about new_gc.

Here's is the function:

def draw_arcs(widget, x, y):
   fill = 0
   color = GdkColor(0.1,0.3,0.8)
   # create a new GdkGC with the color in color and pass to draw_arc?
   widget.draw_arc(widget.get_style().black_gc, fill, x, y,
                   60,60,
                   0,360*64)
   return TRUE


This function is based on 'draw_brushes' in the demo
examples/simple/scribble.py.

Thanks,
John Hunter

pygtk-0.6.8