You want to use something more like this:
  widget_style = widget.get_style().copy()
  widget_style.bg[STATE_NORMAL] = widget.get_colormap().alloc(0xffff,0,0)
  widget.set_style(widget_style)

James.

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


On Thu, 3 Jun 1999, J.W. Bizzaro wrote:

> So I try something like this?
> 
>     widget_style = widget.get_style().copy
>     widget.set_style(widget_style).bg[STATE_NORMAL] = (1, 0, 0)
> 
> But I get this:
> 
>     TypeError: gtk_widget_set_style, argument 2: expected GtkStyle,
> builtin_function_or_method found
> 
> Is this the "style's copy() method"?
> 
>     widget.get_style().copy
> 
> One might also think this would work:
> 
>     widget_style = widget.get_style()
>     widget.set_style(widget_style).bg[STATE_NORMAL] = (1, 0, 0)
> 
> But I get this:
> 
>     AttributeError: 'None' object has no attribute 'bg'
> 
> 
> :-)
> Jeff
> 
> 
> 
> James Henstridge wrote:
> > 
> > To copy a style, use the style's copy() method.  THen using get_style()
> > and set_style() you should be able to modify styles as much as you want.
> > I don't have a python example of this, but there is an example of doing
> > this in my gnorpm package (specifically the checksig.c file).
> > 
> > James.
> > 
> > --
> > Email: [EMAIL PROTECTED]
> > WWW:   http://www.daa.com.au/~james/
> > 
> > On Thu, 3 Jun 1999, J.W. Bizzaro wrote:
> > 
> > > Some of the style-setting functions of gtk are in pygtk, such as
> > >
> > >     widget.set_style(stylename).fg[STATE_NORMAL] = (1, 0, 0)
> > >     widget.get_style().fg[STATE_NORMAL]
> > >
> > > But the problem is with "stylename".
> > >
> > > set_style expects a GdkStyle type to be passed, but how do we get that?
> > >
> > > Gtk has these 4 functions:
> > >
> > >     gtk_widget_get_default_style ()
> > >     gtk_style_copy (stylename)
> > >     gtk_widget_push_style (stylename)
> > >     gtk_widget_pop_style (stylename)
> > >
> > > which don't seem to be included in pygtk.
> > >
> > > What am I to do?  I want to switch styles on the fly.  I am using a style rc
> > > file, as is used with the example testgtk.  But I need to switch between them
> > > during runtime or be able to change parts of the default style at the very
> > > least.
> > >
> 
> -- 
> J.W. Bizzaro                  mailto:[EMAIL PROTECTED]
> Boston College Chemistry      http://www.uml.edu/Dept/Chem/Bizzaro/
> --
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
> 

To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]

Reply via email to