The buttons are most likely sharing the same style object.  To get around
this, use code like:

  # get a copy of the style object ...
  style = button.get_style().copy()
  style.whatever = somevalue
  button.set_style(style)

Alternatively, use:
  button.set_name('button_name')

And have an rc file like:
  style "button_style"
  {
    bg[NORMAL] = { 1.0, 0.0, 0.0 }
  }
  widget "*button_name" style "button_style"

And in your program startup, read this file in with the rc_parse()
function.  This allows the user to change the colours without editing your
code.

James.

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


On Thu, 4 Nov 1999, Rob Hodges wrote:

> > But how can I obtain the window's position within the root
> > window (and for that matter, the dimensions of the root window)?  
> 
> I figured out the answers to these -- self.get_window().x and
> self.get_window().y and screen_width(), screen_height().  
> 
> But now I'm really stuck.  Quite simply, I want to be able to change
> the colours of individual buttons.  For any one GtkButton 'but',
> 
> but.get_style().bg_gc[STATE_NORMAL].foreground = \
>        _gtk.gdk_color_alloc(but._o,60000,0,0)
> 
> will make *all* of my buttons red.  (Obviously I'd use a colour
> selection dialog to obtain the colour; this is just testing code.)
> What (I think) I really want to set is
> 
> but.get_style().bg[STATE_NORMAL]
> 
> which also returns the colour of the button.  However, there is only a
> getattr method for it in gtkmodule; no setattr, so I get no result
> from assigning a gdkcolor to it.  Am I completely on the wrong track?
> How should I really be going about this?
> 
> (I know in general you shouldn't override the current theme, but I
> only intend to do it at the user's behest -- the app consists only of
> a large number of buttons and the user should be able to colour-code
> them in order to find them quickly.)
> 
> -Rob
> 
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
> 

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

Reply via email to