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.

CSS nodes

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.

Other style classes that are commonly used with 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 ToggleButton, MenuButton, VolumeButton, LockButton, ColorButton, FontButton or FileChooserButton use style classes such as .toggle, .popup, .scale, .lock, .color, .font, .file to differentiate themselves from a plain Button.

Implements

ButtonExt, BinExt, ContainerExt, WidgetExt, glib::object::ObjectExt, BuildableExt, ActionableExt

Methods

impl Button
[src]

[src]

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

Returns

The newly created Button widget.

[src]

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

icon_name

an icon name or None

size

an icon size (IconSize)

Returns

a new Button displaying the themed icon

[src]

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.

stock_id

the name of the stock item

Returns

a new Button

[src]

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

label

The text you want the Label to hold.

Returns

The newly created Button widget.

[src]

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.

label

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

Returns

a new Button

Trait Implementations

impl Clone for Button

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Button

Formats the value using the given formatter. Read more

impl Hash for Button

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

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

1.0.0
[src]

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<Buildable> for Button

impl IsA<Actionable> for Button

impl IsA<Object> for Button

impl Default for Button
[src]

[src]

Returns the "default value" for a type. Read more

impl IsA<Button> for CheckButton

impl IsA<Button> for ColorButton

impl IsA<Button> for FontButton

impl IsA<Button> for LinkButton

impl IsA<Button> for MenuButton

impl IsA<Button> for ModelButton

impl IsA<Button> for RadioButton

impl IsA<Button> for ScaleButton

impl IsA<Button> for ToggleButton

impl IsA<Button> for VolumeButton