Create buttons which retain their state
Class GtkToggleButton
A GtkToggleButton is a GtkButton which will remain 'pressed-in' when clicked. Clicking again will cause the toggle button to return to its normal state.
The state of a GtkToggleButton can be set specifically using set_active(), and retrieved using get_active().
To simply switch the state of a toggle button, use toggled().
Methods | |
get_active | Queries a GtkToggleButton and returns its current state. |
get_inconsistent | Gets the value set by set_inconsistent(). |
get_mode | Retrieves whether the button is displayed as a separate indicator and label. |
new_with_label | Creates a new toggle button with a text label. |
new_with_mnemonic | Creates a new GtkToggleButton containing a label. |
set_active | Sets the status of the toggle button. |
set_inconsistent | Sets the button consistency state. |
set_mode | Sets whether the button is displayed as a separate indicator and label. |
signal_toggled | Should be connected if you wish to perform an action whenever the GtkToggleButton's state is changed. |
toggled | Emits the toggled signal on the GtkToggleButton. |
Queries a GtkToggleButton and returns its current state.
GtkToggleButton.get_active()
Return | true if the toggle button is pressed in and false if it is raised. |
Gets the value set by set_inconsistent().
GtkToggleButton.get_inconsistent()
Return | (boolean) true if the button is displayed as inconsistent, false otherwise |
Retrieves whether the button is displayed as a separate indicator and label.
GtkToggleButton.get_mode()
Return | (boolean) true if the togglebutton is drawn as a separate indicator and label. |
Creates a new toggle button with a text label.
GtkToggleButton.new_with_label( label )
label | a string containing the message to be placed in the toggle button. |
Return | a new toggle button. |
Creates a new GtkToggleButton containing a label.
GtkToggleButton.new_with_mnemonic( label )
label | the text of the button, with an underscore in front of the mnemonic character |
Return | a new toggle button. |
The label will be created using gtk_label_new_with_mnemonic(), so underscores in label indicate the mnemonic for the button.
Sets the status of the toggle button.
GtkToggleButton.set_active( is_active )
is_active | Set to true if you want the GtkToggleButton to be 'pressed in', and false to raise it. |
This action causes the toggled signal to be emitted.
Sets the button consistency state.
GtkToggleButton.set_inconsistent( setting )
setting | (boolean) true if state is inconsistent |
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, you may want to display the toggle in an "in between" state. This function turns on "in between" display. Normally you would turn off the inconsistent state again if the user toggles the toggle button. This has to be done manually, set_inconsistent() only affects visual appearance, it doesn't affect the semantics of the button.
Sets whether the button is displayed as a separate indicator and label.
GtkToggleButton.set_mode( draw_indicator )
draw_indicator | (boolean) if true, draw the button as a separate indicator and label; if false, draw the button like a normal button |
You can call this function on a checkbutton or a radiobutton with draw_indicator = false to make the button look like a normal button
This function only affects instances of classes like GtkCheckButton and GtkRadioButton that derive from GtkToggleButton, not instances of GtkToggleButton itself.
Should be connected if you wish to perform an action whenever the GtkToggleButton's state is changed.
GtkToggleButton.signal_toggled()
Emits the toggled signal on the GtkToggleButton.
GtkToggleButton.toggled()
There is no good reason for an application ever to call this function.