Package: gtk

Class gtk:button

Superclasses

Documented Subclasses

Direct Slots

can-shrink
The can-shrink property of type :boolean (Read / Write)
Whether the size of the button can be made smaller than the natural size of its contents. For text buttons, setting this property will allow ellipsizing the label. If the contents of a button are an icon or a custom widget, setting this property has no effect. Since 4.12
Default value: false
child
The child property of type gtk:widget (Read / Write)
The child widget.
Default value: nil
has-frame
The has-frame property of type :boolean (Read / Write)
Whether the button has a frame.
Default value: true
icon-name
The icon-name property of type :string (Read / Write)
The name of the icon used to automatically populate the button.
Default value: nil
label
The label property of type :string (Read / Write)
The text of the label inside the button, if the button contains a label.
Default value: nil
use-underline
The use-underline property of type :boolean (Read / Write)
If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key.
Default value: false

Details

The gtk:button widget is generally used to trigger a callback function that is called when the button is pressed.

Figure: GtkButton

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. When activating a button from the keyboard, it will temporarily acquires the .keyboard-activating style class.

Other style classes that are commonly used with the gtk:button implementation include the .suggested-action and .destructive-action style classes. In special cases, buttons can be made round by adding the .circular style class.

Button-like widgets like the gtk:toggle-button, gtk:menu-button, gtk:volume-button, gtk:lock-button, gtk:color-button or gtk:font-button widgets use style classes such as the .toggle, .popup, .scale, .lock, .color style classes on the button node to differentiate themselves from a plain gtk:button widget.

Signal Details

The "activate" signal
lambda (button)    :action      
button
The gtk:button widget which received the signal.
This signal 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.
The "clicked" signal
lambda (button)    :action      
button
The gtk:button widget which received the signal.
Emitted when the button has been activated (pressed and released).
 

Returned by

Slot Access Functions

Inherited Slot Access Functions

See also

2024-10-31