gtk.button

Module for [Button] class

Types 3

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

!An example GtkButton

The gtk.button.Button widget can hold any valid child widget. That is, it can hold almost any other standard gtk.widget.Widget. The most commonly used child is the gtk.label.Label.

CSS nodes

gtk.button.Button has a single CSS node with name button. The node will get the style classes .image-button or .text-button, if the content is just an image or label, respectively. It may also receive the .flat style class. When activating a button via the keyboard, the button will temporarily gain the .keyboard-activating style class.

Other style classes that are commonly used with gtk.button.Button 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.ToggleButton, gtk.menu_button.MenuButton, gtk.volume_button.VolumeButton, gtk.lock_button.LockButton, gtk.color_button.ColorButton or gtk.font_button.FontButton use style classes such as .toggle, .popup, .scale, .lock, .color on the button node to differentiate themselves from a plain gtk.button.Button.

Accessibility

gtk.button.Button uses the gtk.types.AccessibleRole.Button role.

Methods
GType _getGType() static nothrow
GType _gType() @property nothrow
Button self() nothrowReturns `this`, for use in `with` statements.
ButtonGidBuilder builder() static nothrowGet builder for [gtk.button.Button] Returns: New builder object
bool canShrink() @property nothrowGet `canShrink` property. Returns: Whether the size of the button can be made smaller than the natural size of its contents.
void canShrink(bool propval) @property nothrowSet `canShrink` property. Params: propval = Whether the size of the button can be made smaller than the natural size of its contents.
gtk.widget.Widget child() @property nothrowGet `child` property. Returns: The child widget.
void child(gtk.widget.Widget propval) @property nothrowSet `child` property. Params: propval = The child widget.
bool hasFrame() @property nothrowGet `hasFrame` property. Returns: Whether the button has a frame.
void hasFrame(bool propval) @property nothrowSet `hasFrame` property. Params: propval = Whether the button has a frame.
string iconName() @property nothrowGet `iconName` property. Returns: The name of the icon used to automatically populate the button.
void iconName(string propval) @property nothrowSet `iconName` property. Params: propval = The name of the icon used to automatically populate the button.
string label() @property nothrowGet `label` property. Returns: Text of the label inside the button, if the button contains a label widget.
void label(string propval) @property nothrowSet `label` property. Params: propval = Text of the label inside the button, if the button contains a label widget.
bool useUnderline() @property nothrowGet `useUnderline` property. Returns: If set, an underline in the text indicates that the following character is to be used as mnemonic.
void useUnderline(bool propval) @property nothrowSet `useUnderline` property. Params: propval = If set, an underline in the text indicates that the following character is to be used as mnemonic.
gtk.button.Button newFromIconName(string iconName) static nothrowCreates a new button containing an icon from the current icon theme.
gtk.button.Button newWithLabel(string label) static nothrowCreates a [gtk.button.Button] widget with a [gtk.label.Label] child.
gtk.button.Button newWithMnemonic(string label) static nothrowCreates a new [gtk.button.Button] containing a label.
bool getCanShrink() nothrowRetrieves whether the button can be smaller than the natural size of its contents. Returns: true if the button can shrink, and false otherwise
gtk.widget.Widget getChild() nothrowGets the child widget of button. Returns: the child widget of button
bool getHasFrame() nothrowReturns whether the button has a frame. Returns: true if the button has a frame
string getIconName() nothrowReturns the icon name of the button.
string getLabel() nothrowFetches the text from the label of the button.
bool getUseUnderline() nothrowgets whether underlines are interpreted as mnemonics.
void setCanShrink(bool canShrink) nothrowSets whether the button size can be smaller than the natural size of its contents.
void setChild(gtk.widget.Widget child = null) nothrowSets the child widget of button.
void setHasFrame(bool hasFrame) nothrowSets the style of the button.
void setIconName(string iconName) nothrowAdds a [gtk.image.Image] with the given icon name as a child.
void setLabel(string label) nothrowSets the text of the label of the button to label.
void setUseUnderline(bool useUnderline) nothrowSets whether to use underlines as mnemonics.
gulong connectActivate(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.button.Button))) && Parameters!T.length < 2) nothrowConnect to `Activate` signal.
gulong connectClicked(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.button.Button))) && Parameters!T.length < 2) nothrowConnect to `Clicked` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new [gtk.button.Button] widget.

Fluent builder implementation template for gtk.button.Button

Methods
T canShrink(bool propval) nothrowSet `canShrink` property. Params: propval = Whether the size of the button can be made smaller than the natural size of its contents.
T child(gtk.widget.Widget propval) nothrowSet `child` property. Params: propval = The child widget. Returns: Builder instance for fluent chaining
T hasFrame(bool propval) nothrowSet `hasFrame` property. Params: propval = Whether the button has a frame. Returns: Builder instance for fluent chaining
T iconName(string propval) nothrowSet `iconName` property. Params: propval = The name of the icon used to automatically populate the button. Returns: Builder instance for fluent chaining
T label(string propval) nothrowSet `label` property. Params: propval = Text of the label inside the button, if the button contains a label widget. Returns: Builder instance for fluent chaining
T useUnderline(bool propval) nothrowSet `useUnderline` property. Params: propval = If set, an underline in the text indicates that the following character is to be used as mnemonic. Returns: Builder instance for fluent chaining

Fluent builder for gtk.button.Button

Methods
Button build() nothrowCreate object from builder. Returns: New object