gtk.ToggleButton — a button that retains its state
class gtk.ToggleButton(gtk.Button): |
+--gobject.GObject +-- gtk.Object +-- gtk.Widget +-- gtk.Container +-- gtk.Bin +-- gtk.Button +-- gtk.ToggleButton
|
gtk.Container Signal Prototypes
"toggled" | def callback( |
A gtk.ToggleButton
is a gtk.Button
that has
two stable states: 'pressed-in' ("on" or "active") and "normal" ("off" or
"inactive"). The state changes to the alternate state each time the
togglebutton is clicked. The state of a gtk.ToggleButton
can be set specifically using the set_active
()
method, and retrieved using the get_active
()
method. To simply switch the state of a toggle button, use the toggled
()
method.
gtk.ToggleButton(label
=None, use_underline
=True)
| the text to be displayed by the button label
including an underscore to indicate the mnemonic character if desired or
None if no label is required. |
| if True , an underscore in the
label text indicates the next character should be underlined and used for the
mnemonic accelerator key if it is the first character so
marked. Available in PyGTK 2.4 and above. |
Returns : | a new gtk.ToggleButton
widget |
Creates a new gtk.ToggleButton
widget with the text label specified by label
.
label
will be parsed for underscore characters that
indicate mnemonic accelerators. If label
is
None
or not specified, no label will be created.
In PyGTK 2.4 and above the use_underline
parameter is available and defaults to True
. If
use_underline
is set to False
the
label text will not be parsed for mnemonic characters.
def set_mode(draw_indicator
)
| if True display the button
as an indicator with a label; if False just display as a
normal button |
The set_mode
() method sets the
"draw-indicator" property to the value of
draw_indicator
. If draw_indicator
is
True
the button is displayed as an indicator with a
label; otherwise, the button is displayed as a normal button.
This method only affects subclasses of gtk.ToggleButton
like gtk.CheckButton
and gtk.RadioButton
.
def get_mode()
Returns : | True if the button is
displayed as an indicator with a label; False if
displayed as a normal button. |
The get_mode
() method returns the value
of the "draw-indicator" property. If "draw-indicator" is
True
the button is displayed as an indicator with a
label; if False
, the button is displayed as a normal
button. See the set_mode
()
method.
def set_active(is_active
)
| if True the togglebutton
state is active ("on") |
The set_active
() method sets the
"active" property to the value of is_active
. If
is_active
is True
the gtk.ToggleButton
is 'pressed in', and if False
it's 'normal'. This method
causes the "toggled" signal to be emitted.
def get_active()
Returns : | True if the togglebutton is active |
The get_active
() method returns the
value of the "active" property. If "active" is True
the
togglebutton is 'pressed in'; if False
, it's
'normal'.
def toggled()
The toggled
() method emits the
"toggled" signal on the togglebutton.
def set_inconsistent(setting
)
| if True the state is
inconsistent |
The set_inconsistent
() method sets the
"inconsistent" property to the value of setting
. If
setting
is True
the togglebutton
is displayed in the inconsistent state - an "in between" state. This method
is useful if the user has selected a range of elements (such as some text or
spreadsheet cells) that are affected by a toggle button, and the current
values in that range are inconsistent and you want to indicate that by
setting the toggle button to an "in between" display. Normally you would
turn off the inconsistent state again if the user clicks the toggle
button.
def get_inconsistent()
Returns : | True if the state is
inconsistent |
The get_inconsistent
() method returns
the value of the "inconsistent" property. If "inconsistent" is
True
the togglebutton is displayed in an 'in between'
state. See the set_inconsistent
()
method for more details.
def callback(togglebutton
, user_param1
, ...
)
| the togglebutton that received the signal |
| the first user parameter (if any) specified
with the connect () |
| additional user parameters (if any) |
The "toggled" signal is emitted when the togglebutton state changes either programmatically or by user action.