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.
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.
ButtonGidBuilder builder() static nothrowGet builder for [gtk.button.Button] Returns: New builder objectbool 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.void child(gtk.widget.Widget propval) @property nothrowSet `child` property. Params: propval = The child widget.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 otherwisegtk.widget.Widget getChild() nothrowGets the child widget of button. Returns: the child widget of buttonbool getHasFrame() nothrowReturns whether the button has a frame. Returns: true if the button has a framevoid setCanShrink(bool canShrink) nothrowSets whether the button size can be smaller than the natural size of its contents.void setIconName(string iconName) nothrowAdds a [gtk.image.Image] with the given icon name as a child.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.Fluent builder implementation template for gtk.button.Button
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 chainingT hasFrame(bool propval) nothrowSet `hasFrame` property. Params: propval = Whether the button has a frame. Returns: Builder instance for fluent chainingT iconName(string propval) nothrowSet `iconName` property. Params: propval = The name of the icon used to automatically populate the button. Returns: Builder instance for fluent chainingT 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 chainingT 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 chainingFluent builder for gtk.button.Button