11.33Class GtkButton

A widget that creates a signal when clicked on

Class GtkButton

The GtkButton widget is generally used to attach a function to that is called when the button is pressed. The various signals and how to use them are outlined below.

The GtkButton widget can hold any valid child widget. That is it can hold most any other standard GtkWidget. The most commonly used child is the GtkLabel.

Methods
clickedEmits a "clicked" signal to the given GtkButton.
enterEmits a "enter" signal to the given GtkButton.
get_alignmentGets the alignment of the child in the button.
get_focus_on_clickReturns whether the button grabs focus when it is clicked with the mouse.
get_imageGets the widget that is currenty set as the image of button.
get_image_positionGets the position of the image relative to the text inside the button.
get_labelFetches the text from the label of the button.
get_reliefReturns the current relief style of the given GtkButton.
get_use_stockReturns whether the button label is a stock item.
get_use_underlineReturns whether an embedded underline in the button label indicates a mnemonic.
leaveEmits a "leave" signal to the given GtkButton.
new_from_stockCreates a new GtkButton containing the image and text from a stock item.
new_with_labelCreates a GtkButton widget with a GtkLabel child containing the given text.
new_with_mnemonicCreates a new GtkButton containing a label.
pressedEmits a "pressed" signal to the given GtkButton.
releasedEmits a "released" signal to the given GtkButton.
set_alignmentSets the alignment of the child.
set_focus_on_clickSets whether the button will grab focus when it is clicked with the mouse.
set_imageSet the image of button to the given widget.
set_image_positionSets the position of the image relative to the text inside the button.
set_labelSets the text of the label of the button.
set_reliefSets the relief style of the edges of the given GtkButton widget.
set_use_stockUse a stock id.
set_use_underlineSets an underline.
signal_activateThe activate signal on GtkButton is an action signal and emitting it causes the button to animate press then release.
signal_clickedEmitted when the button has been activated (pressed and released).
signal_enterEmitted when the pointer enters the button.
signal_leaveEmitted when the pointer leaves the button.
signal_pressedEmitted when the button is pressed.
signal_releasedEmitted when the button is released.

Methods

clicked

Emits a "clicked" signal to the given GtkButton.

GtkButton.clicked()

enter

Emits a "enter" signal to the given GtkButton.

GtkButton.enter()

get_alignment

Gets the alignment of the child in the button.

GtkButton.get_alignment()
Returnan array [ horizontal alignment, vertical alignment ]

get_focus_on_click

Returns whether the button grabs focus when it is clicked with the mouse.

GtkButton.get_focus_on_click()
ReturnTRUE if the button grabs focus when it is clicked with the mouse.

get_image

Gets the widget that is currenty set as the image of button.

GtkButton.get_image()
Returna GtkWidget or nil in case there is no image

This may have been explicitly set by gtk_button_set_image() or constructed by gtk_button_new_from_stock().

get_image_position

Gets the position of the image relative to the text inside the button.

GtkButton.get_image_position()
Returnthe position (GtkPositionType).

get_label

Fetches the text from the label of the button.

GtkButton.get_label()
ReturnThe text of the label widget, or nil.

If the label text has not been set the return value will be NULL. This will be the case if you create an empty button with gtk_button_new() to use as a container.

get_relief

Returns the current relief style of the given GtkButton.

GtkButton.get_relief()
ReturnThe current GtkReliefStyle.

get_use_stock

Returns whether the button label is a stock item.

GtkButton.get_use_stock()
ReturnTRUE if the button label is used to select a stock item instead of being used directly as the label text.

get_use_underline

Returns whether an embedded underline in the button label indicates a mnemonic.

GtkButton.get_use_underline()
ReturnTRUE if an embedded underline in the button label indicates the mnemonic accelerator keys.

leave

Emits a "leave" signal to the given GtkButton.

GtkButton.leave()

new_from_stock

Creates a new GtkButton containing the image and text from a stock item.

GtkButton.new_from_stock( stock_id )
stock_id the name of the stock item
Returna new GtkButton

Some stock ids have preprocessor macros like GTK_STOCK_OK and GTK_STOCK_APPLY.

If stock_id is unknown, then it will be treated as a mnemonic label (as for gtk_button_new_with_mnemonic()).

new_with_label

Creates a GtkButton widget with a GtkLabel child containing the given text.

GtkButton.new_with_label( label )
label The text you want the GtkLabel to hold.
ReturnThe newly created GtkButton widget.

new_with_mnemonic

Creates a new GtkButton containing a label.

GtkButton.new_with_mnemonic( label )
label The text of the button, with an underscore in front of the mnemonic character
Returna new GtkButton

If characters in label are preceded by an underscore, they are underlined. If you need a literal underscore character in a label, use '' (two underscores). The first underlined character represents a keyboard accelerator called a mnemonic. Pressing Alt and that key activates the button.

pressed

Emits a "pressed" signal to the given GtkButton.

GtkButton.pressed()

released

Emits a "released" signal to the given GtkButton.

GtkButton.released()

set_alignment

Sets the alignment of the child.

GtkButton.set_alignment( xalign, yalign )
xalign the horizontal position of the child, 0.0 is left aligned, 1.0 is right aligned
yalign the vertical position of the child, 0.0 is top aligned, 1.0 is bottom aligned

This property has no effect unless the child is a GtkMisc or a GtkAligment.

set_focus_on_click

Sets whether the button will grab focus when it is clicked with the mouse.

GtkButton.set_focus_on_click( focus_on_click )
focus_on_click whether the button grabs focus when clicked with the mouse

Making mouse clicks not grab focus is useful in places like toolbars where you don't want the keyboard focus removed from the main area of the application.

set_image

Set the image of button to the given widget.

GtkButton.set_image( image )
image a widget to set as the image for the button.

Note that it depends on the "gtk-button-images" setting whether the image will be displayed or not, you don't have to call gtk_widget_show() on image yourself.

set_image_position

Sets the position of the image relative to the text inside the button.

GtkButton.set_image_position( position )
position the position (GtkPositionType).

set_label

Sets the text of the label of the button.

GtkButton.set_label( label )
label a string

This text is also used to select the stock item if gtk_button_set_use_stock() is used. This will also clear any previously set labels.

set_relief

Sets the relief style of the edges of the given GtkButton widget.

GtkButton.set_relief( newstyle )
newstyle The new GtkReliefStyle.

Three styles exist, GTK_RELIEF_NORMAL, GTK_RELIEF_HALF, GTK_RELIEF_NONE. The default style is, as one can guess, GTK_RELIEF_NORMAL.

set_use_stock

Use a stock id.

GtkButton.set_use_stock( use_stock )
use_stock TRUE if the button should use a stock item

If true, the label set on the button is used as a stock id to select the stock item for the button.

set_use_underline

Sets an underline.

GtkButton.set_use_underline( use_underline )
use_underline TRUE if underlines in the text indicate mnemonics

If true, an underline in the text of the button label indicates the next character should be used for the mnemonic accelerator key.

signal_activate

The activate signal on GtkButton is an action signal and emitting it causes the button to animate press then release.

GtkButton.signal_activate()

Applications should never connect to this signal, but use the "clicked" signal.

signal_clicked

Emitted when the button has been activated (pressed and released).

GtkButton.signal_clicked()

signal_enter

Emitted when the pointer enters the button.

GtkButton.signal_enter()

GtkButton::enter has been deprecated since version 2.8 and should not be used in newly-written code. Use the "enter-notify-event" signal.

signal_leave

Emitted when the pointer leaves the button.

GtkButton.signal_leave()

GtkButton::leave has been deprecated since version 2.8 and should not be used in newly-written code. Use the Widget "leave-notify-event" signal.

signal_pressed

Emitted when the button is pressed.

GtkButton.signal_pressed()

GtkButton::pressed has been deprecated since version 2.8 and should not be used in newly-written code. Use the Widget "button-press-event" signal.

signal_released

Emitted when the button is released.

GtkButton.signal_released()

GtkButton::released has been deprecated since version 2.8 and should not be used in newly-written code. Use the Widget "button-release-event" signal.

Made with http://www.falconpl.org