Steve McClure wrote:

>On Mon, 2002-04-29 at 15:46, Janos Blazi wrote:
>  
>
>>How can I set the colours of a widget in PyGtk?
>>
>>In C I could try
>>
>>GdkColor col;   
>>gdk_color_parse ("red", &col);   gtk_widget_modify_bg(widget,
>>GTK_STATE_NORMAL, &col);
>>
>>I tried 
>>col=gtk.gdk.Color()
>>but this does not seem to work.
>>    
>>
>
>That allocates the color then you have to assign the color to a widgets
>style. e.g.
>
>color = wid.get_colormap().alloc("red")
>s = wid.get_style().copy()
>s.fg[gtk.STATE_NORMAL] = color
>
>If you don't use the copy() when you get the style you will change the
>color on every widget using that style.
>  
>
You should be able to use widget.modify_bg() to replace the last two 
lines in your example.  Making a gtk.gdk.Color() constructor is also in 
the TODO list (it would set r, g, b and leave pixel as 0 -- many gtk 
functions will allocate colours if you leave pixel blank).

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/




_______________________________________________
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