ons 2003-03-05 klockan 20.47 skrev Dan Christian:
> I'd like to change the color of a ToggleButton when it is pushed in: 
> preferably the background color, but the text color would work too.
> 
> I would guess that you can do this by setting the right color for the 
> right state.  However, I can't find any documention about what state 
> applies when.  This is probably obvious to the experts, but it needs a 
> lot more discussion for a beginner like me.  For example, how is 
> "active" different from "selected"?  What state is a toggle in when it 
> is "pressed"?
> 
> Even worse, I don't know when to change with the button itself and when 
> to change the label that displays the text (it's child).
> 
> I've tried everything that seemed obvious with no success.

>From the reference manual[1]:
(the defines are accessed in pygtk through gtk.STATE_...)

This type indicates the current state of a widget; the state determines
how the widget is drawn. The GtkStateType enumeration is also used to
identify different colors in a GtkStyle for drawing, so states can be
used for subparts of a widget as well as entire widgets.

GTK_STATE_NORMAL
State during normal operation.

GTK_STATE_ACTIVE
State of a currently active widget,
such as a depressed button.

GTK_STATE_PRELIGHT
State indicating that the mouse
pointer is over the widget and the
widget will respond to mouse clicks.

GTK_STATE_SELECTED
State of a selected item, such the
selected row in a list.

GTK_STATE_INSENSITIVE
State indicating that the widget is
unresponsive to user actions.


Use widget.modify_bg(state, color), eg:

button.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.color_parse("#00ff00"))


[1]
http://developer.gnome.org/doc/API/2.0/gtk/gtk-Standard-Enumerations.html#GtkStateType

-- 
Johan Dahlin <[EMAIL PROTECTED]>
Async Open Source

_______________________________________________
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