Struct gtk::Button []

pub struct Button(_, _);

The 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 Button widget can hold any valid child widget. That is, it can hold almost any other standard Widget. The most commonly used child is the Label.


ButtonExt, BinExt, ContainerExt, WidgetExt, ObjectExt, ActionableExt


impl Button

Creates a new Button widget. To add a child widget to the button, use Container::add.


The newly created Button widget.

Creates a new button containing an icon from the current icon theme.

If the icon name isn’t known, a “broken image” icon will be displayed instead. If the current icon theme is changed, the icon will be updated appropriately.

This function is a convenience wrapper around Button::new and ButtonExt::set_image.

Feature: v3_10


an icon name


an icon size


a new Button displaying the themed icon

Creates a new 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 Button::new_with_mnemonic).

Deprecated since 3.10

Use Button::new_with_label instead.


the name of the stock item


a new Button

Creates a Button widget with a Label child containing the given text.


The text you want the Label to hold.


The newly created Button widget.

Creates a new 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.


The text of the button, with an underscore in front of the mnemonic character


a new Button

Trait Implementations

impl Clone for Button

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for Button

Formats the value using the given formatter.

impl Hash for Button

Feeds this value into the state given, updating the hasher as necessary.

Feeds a slice of this type into the state provided.

impl StaticType for Button

Returns the type identifier of Self.

impl<T: IsA<Object>> PartialEq<T> for Button

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for Button

impl IsA<Bin> for Button

impl IsA<Container> for Button

impl IsA<Widget> for Button

impl IsA<Actionable> for Button

impl IsA<Object> for Button