A widget that creates a signal when clicked on
The <gtk-button>
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 <gtk-button>
widget can hold any valid child widget. That is it can
hold most any other standard <gtk-widget>
. The most commonly used child
is the <gtk-label>
.
Derives from
<gtk-bin>
.This class defines the following slots:
label
- Text of the label widget inside the button, if the button contains a label widget
image
- Child widget to appear next to the button text
relief
- The border relief style
use-underline
- If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key
use-stock
- If set, the label is used to pick a stock item instead of being displayed
focus-on-click
- Whether the button grabs focus when it is clicked with the mouse
xalign
- Horizontal position of child in available space. 0.0 is left aligned, 1.0 is right aligned
yalign
- Vertical position of child in available space. 0.0 is top aligned, 1.0 is bottom aligned
image-position
- The position of the image relative to the text
The "activate" signal on GtkButton is an action signal and emitting it causes the button to animate press then release. Applications should never connect to this signal, but use the "clicked" signal.
Emitted when the button is pressed.
deprecated: Use the GtkWidget::button-press-event signal.
Emitted when the button is released.
deprecated: Use the GtkWidget::button-release-event signal.
Emitted when the button has been activated (pressed and released).
Emitted when the pointer enters the button.
deprecated: Use the GtkWidget::enter-notify-event signal.
Emitted when the pointer leaves the button.
deprecated: Use the GtkWidget::leave-notify-event signal.
<gtk-widget>
)Creates a new
<gtk-button>
widget. To add a child widget to the button, usegtk-container-add
.
- ret
- The newly created
<gtk-button>
widget.
mchars
) ⇒ (ret <gtk-widget>
)Creates a
<gtk-button>
widget with a<gtk-label>
child containing the given text.
- label
- The text you want the
<gtk-label>
to hold.- ret
- The newly created
<gtk-button>
widget.
mchars
) ⇒ (ret <gtk-widget>
)Creates a new
<gtk-button>
containing a label. 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.
- label
- The text of the button, with an underscore in front of the mnemonic character
- ret
- a new
<gtk-button>
mchars
) ⇒ (ret <gtk-widget>
)Creates a new
<gtk-button>
containing the image and text from a stock item. 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
).
- stock-id
- the name of the stock item
- ret
- a new
<gtk-button>
<gtk-button>
)Emits a
<gtk-button::pressed>
signal to the given<gtk-button>
.
- button
- The
<gtk-button>
you want to send the signal to.
<gtk-button>
)Emits a
<gtk-button::released>
signal to the given<gtk-button>
.
- button
- The
<gtk-button>
you want to send the signal to.
<gtk-button>
)Emits a
<gtk-button::clicked>
signal to the given<gtk-button>
.
- button
- The
<gtk-button>
you want to send the signal to.
<gtk-button>
)Emits a
<gtk-button::enter>
signal to the given<gtk-button>
.
- button
- The
<gtk-button>
you want to send the signal to.
<gtk-button>
)Emits a
<gtk-button::leave>
signal to the given<gtk-button>
.
- button
- The
<gtk-button>
you want to send the signal to.
<gtk-button>
) (newstyle <gtk-relief-style>
)Sets the relief style of the edges of the given
<gtk-button>
widget. Three styles exist, GTK_RELIEF_NORMAL, GTK_RELIEF_HALF, GTK_RELIEF_NONE. The default style is, as one can guess, GTK_RELIEF_NORMAL.
- button
- The
<gtk-button>
you want to set relief styles of.- newstyle
- The GtkReliefStyle as described above.
<gtk-button>
) ⇒ (ret <gtk-relief-style>
)Returns the current relief style of the given
<gtk-button>
.
- button
- The
<gtk-button>
you want the<gtk-relief-style>
from.- ret
- The current
<gtk-relief-style>
<gtk-button>
) ⇒ (ret mchars
)Fetches the text from the label of the button, as set by
gtk-button-set-label
. If the label text has not been set the return value will be ‘#f
’. This will be the case if you create an empty button withgtk-button-new
to use as a container.
- button
- a
<gtk-button>
- ret
- The text of the label widget. This string is owned by the widget and must not be modified or freed.
<gtk-button>
) (label mchars
)Sets the text of the label of the button to str. 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.
- button
- a
<gtk-button>
- label
- a string
<gtk-button>
) ⇒ (ret bool
)Returns whether the button label is a stock item.
- button
- a
<gtk-button>
- ret
- ‘
#t
’ if the button label is used to select a stock item instead of being used directly as the label text.
<gtk-button>
) (use_stock bool
)If true, the label set on the button is used as a stock id to select the stock item for the button.
- button
- a
<gtk-button>
- use-stock
- ‘
#t
’ if the button should use a stock item
<gtk-button>
) ⇒ (ret bool
)Returns whether an embedded underline in the button label indicates a mnemonic. See
gtk-button-set-use-underline
.
- button
- a
<gtk-button>
- ret
- ‘
#t
’ if an embedded underline in the button label indicates the mnemonic accelerator keys.
<gtk-button>
) (use_underline bool
)If true, an underline in the text of the button label indicates the next character should be used for the mnemonic accelerator key.
- button
- a
<gtk-button>
- use-underline
- ‘
#t
’ if underlines in the text indicate mnemonics
<gtk-button>
) (focus_on_click bool
)Sets whether the button will grab focus when it is 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.
- button
- a
<gtk-button>
- focus-on-click
- whether the button grabs focus when clicked with the mouse
Since 2.4
<gtk-button>
) ⇒ (ret bool
)Returns whether the button grabs focus when it is clicked with the mouse. See
gtk-button-set-focus-on-click
.
- button
- a
<gtk-button>
- ret
- ‘
#t
’ if the button grabs focus when it is clicked with the mouse.Since 2.4
<gtk-button>
) (xalign float
) (yalign float
)Sets the alignment of the child. This property has no effect unless the child is a
<gtk-misc>
or a<gtk-aligment>
.
- button
- a
<gtk-button>
- 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
Since 2.4
<gtk-button>
) ⇒ (xalign float
) (yalign float
)Gets the alignment of the child in the button.
- button
- a
<gtk-button>
- xalign
- return location for horizontal alignment
- yalign
- return location for vertical alignment
Since 2.4
<gtk-button>
) (image <gtk-widget>
)Set the image of button to the given widget. 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.
- button
- a
<gtk-button>
- image
- a widget to set as the image for the button
Since 2.6
<gtk-button>
) ⇒ (ret <gtk-widget>
)Gets the widget that is currenty set as the image of button. This may have been explicitly set by
gtk-button-set-image
or constructed bygtk-button-new-from-stock
.
- button
- a
<gtk-button>
- ret
- a
<gtk-widget>
or ‘#f
’ in case there is no imageSince 2.6