A widget that emits a signal when clicked on.
The
gtk-button widget is generally used to trigger a callback function
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 almost any other standard
gtk-widget object. The most commonly used child is the
gtk-label widget.
CSS nodes
The
gtk-button implementation has a single CSS node with name
button. The node will get the
.image-button or
.text-button style classes, if the content is just an image or label, respectively. It may also receive the
.flat style class.
Other style classes that are commonly used with the
gtk-button widget include
.suggested-action and
.destructive-action. In special cases, buttons can be made round by adding the
.circular style class.
Button-like widgets like
gtk-toggle-button,
gtk-menu-button,
gtk-volume-button,
gtk-lock-button,
gtk-color-button,
gtk-font-button or
gtk-file-chooser-button use style classes such as
.toggle,
.popup,
.scale,
.lock,
.color,
.font,
.file to differentiate themselves from a plain
gtk-button
widget.
Style Property Details
- child-displacement-x
- The child-displacement-x style property of type :int (Read)
How far in the x direction to move the child when the button is depressed.
Warning: The child-displacement-x style property has been
deprecated since version 3.20 and should not be used in newly written
code. Use CSS margins and padding instead. The value of this style property is ignored.
Default value: 0 - child-displacement-y
- The child-displacement-y style property of type :int (Read)
How far in the y direction to move the child when the button is depressed.
Warning: The child-displacement-x style property has been
deprecated since version 3.20 and should not be used in newly written
code. Use CSS margins and padding instead. The value of this style property is ignored.
Default value: 0 - default-border
- The default-border style property of type gtk-border (Read)
The default-border style property defines the extra space to add
around a button that can become the default widget of its window. For
more information about default widgets, see the gtk-widget-grab-default function.
Warning: The default-border style property has been
deprecated since version 3.14 and should not be used in newly written
code. Use CSS margins and padding instead. The value of this style
property is ignored. - default-outside-border
- The default-outside-border style property of type gtk-border (Read)
The default-outside-border style property defines the extra
outside space to add around a button that can become the default widget
of its window. Extra outside space is always drawn outside the button
border. For more information about default widgets, see the gtk-widget-grab-default function.
Warning: The default-outside-border style property has been
deprecated since version 3.14 and should not be used in newly written
code. Use CSS margins and padding instead. The value of this style
property is ignored. - displace-focus
- The displace-focus style property of type :boolean (Read)
Whether the child-displacement-x or child-displacement-y properties should also affect the focus rectangle.
Warning: The displace-focus style property has been
deprecated since version 3.20 and should not be used in newly written
code. Use CSS margins and padding instead. The value of this style property is ignored.
Default value: false - image-spacing
- The image-spacing style property of type :int (Read)
Spacing in pixels between the image and label.
Allowed values: >= 0
Default value: 2 - inner-border
- The inner-border style property of type gtk-border (Read)
Sets the border between the button edges and child.
Warning: The inner-border style property has been
deprecated since version 3.4 and should not be used in newly written
code. Use the standard border and padding CSS properties. The value of this style property is ignored.
Signal Details
The "activate" signal
lambda (button) :action
The signal on the
gtk-button widget 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.
- button
- The gtk-button widget which received the signal.
The "clicked" signal
lambda (button) :action
Emitted when the button has been activated (pressed and released).
- button
- The gtk-button widget which received the signal.
The "enter" signal
lambda (button) :run-first
Emitted when the pointer enters the button.
Warning: The "enter" signal has been deprecated since version 2.8
and should not be used in newly written code. Use the "enter-notify-event" signal of the
gtk-widget class.
- button
- The gtk-button widget which received the signal.
The "leave" signal
lambda (button) :run-first
Emitted when the pointer leaves the button.
Warning: The "leave" signal has been deprecated since version 2.8
and should not be used in newly written code. Use the "leave-notify-event" signal of the
gtk-widget class.
- button
- The gtk-button widget which received the signal.
The "pressed" signal
lambda (button) :run-first
Emitted when the button is pressed.
Warning: The "pressed" signal has been deprecated since version
2.8 and should not be used in newly written code. Use the "button-press-event" signal of the
gtk-widget class.
- button
- The gtk-button widget which received the signal.
The "released" signal
lambda (button) :run-first
Emitted when the button is released.
Warning: The "released" signal has been deprecated since version
2.8 and should not be used in newly written code. Use the "button-release-event" signal of the
gtk-widget class.
- button
- The gtk-button widget which received the signal.