---
name: "Gtk2::Button"
section: "3pm"
platform: "linux"
package: "libgtk2-perl-doc"
version: "2:1.24992-1"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/Gtk2::Button"
---

# Gtk2::Button(3pm)

wrapper for GtkButton

## NAME

Gtk2::Button - wrapper for GtkButton

## HIERARCHY

```
  Glib::Object
  +----Glib::InitiallyUnowned
       +----Gtk2::Object
            +----Gtk2::Widget
                 +----Gtk2::Container
                      +----Gtk2::Bin
                           +----Gtk2::Button
```

## INTERFACES

```
  Glib::Object::_Unregistered::AtkImplementorIface
  Gtk2::Buildable
  Gtk2::Activatable
```

## MNEMONICS

Mnemonics are "memory aids"; in GTK+, a mnemonic is an underlined character which corresponds to a keyboard accelerator.  For a button, that means pressing Alt and that key activates the button.

For convenience, Gtk2-Perl uses mnemonics by default on widgets that support them.  If characters in label string are preceded by an underscore, they are underlined.  If you need a literal underscore character in a label, use '\_\_' (two underscores).  If you don't want to use mnemonics at all, use the non-mnemonic version explicitly (e.g. `"Gtk2::Button::new_with_label"`).

## METHODS

### widget = Gtk2::Button-\>new

### widget = Gtk2::Button-\>new ($mnemonic)

- •

  `$mnemonic` (string) used to label the widget, see "MNEMONICS"

### widget = Gtk2::Button-\>new\_from\_stock ($stock\_id)

- •

  `$stock_id` (string) creates a new button using the icon and text from the

specified stock item, see Gtk2::Stock

### widget = Gtk2::Button-\>new\_with\_label ($label)

- •

  `$label` (string) used to label the widget

### widget = Gtk2::Button-\>new\_with\_mnemonic ($mnemonic)

- •

  `$mnemonic` (string) used to label the widget, see "MNEMONICS"

### (xalign, yalign) = $button-\>get\_alignment

Since: gtk+ 2.4

### $button-\>set\_alignment ($xalign, $yalign)

- •

  `$xalign` (double)

- •

  `$yalign` (double)

Since: gtk+ 2.4

### $button-\>clicked

### $button-\>enter

### window or undef = $button-\>get\_event\_window

Since: gtk+ 2.22

### boolean = $button-\>get\_focus\_on\_click

Since: gtk+ 2.4

### $button-\>set\_focus\_on\_click ($focus\_on\_click)

- •

  `$focus_on_click` (boolean)

Since: gtk+ 2.4

### widget or undef = $button-\>get\_image

Since: gtk+ 2.6

### positiontype = $button-\>get\_image\_position

Since: gtk+ 2.10

### $button-\>set\_image\_position ($position)

- •

  `$position` (Gtk2::PositionType)

Since: gtk+ 2.10

### $button-\>set\_image ($image)

- •

  `$image` (Gtk2::Widget or undef)

Since: gtk+ 2.6

### string = $button-\>get\_label

### $button-\>set\_label ($label)

- •

  `$label` (string)

### $button-\>leave

### $button-\>pressed

### $button-\>released

### reliefstyle = $button-\>get\_relief

### $button-\>set\_relief ($newstyle)

- •

  `$newstyle` (Gtk2::ReliefStyle)

### boolean = $button-\>get\_use\_stock

### $button-\>set\_use\_stock ($use\_stock)

- •

  `$use_stock` (boolean)

### boolean = $button-\>get\_use\_underline

### $button-\>set\_use\_underline ($use\_underline)

- •

  `$use_underline` (boolean)

## PROPERTIES

- 'focus-on-click' (boolean : default true : readable / writable / private)

  Whether the button grabs focus when it is clicked with the mouse

- 'image' (Gtk2::Widget : default undef : readable / writable / private)

  Child widget to appear next to the button text

- 'image-position' (Gtk2::PositionType : default "left" : readable / writable / private)

  The position of the image relative to the text

- 'label' (string : default undef : readable / writable / construct / private)

  Text of the label widget inside the button, if the button contains a label widget

- 'relief' (Gtk2::ReliefStyle : default "normal" : readable / writable / private)

  The border relief style

- 'use-stock' (boolean : default false : readable / writable / construct / private)

  If set, the label is used to pick a stock item instead of being displayed

- 'use-underline' (boolean : default false : readable / writable / construct / private)

  If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key

- 'xalign' (float : default 0.5 : readable / writable / private)

  Horizontal position of child in available space. 0.0 is left aligned, 1.0 is right aligned

- 'yalign' (float : default 0.5 : readable / writable / private)

  Vertical position of child in available space. 0.0 is top aligned, 1.0 is bottom aligned

## STYLE PROPERTIES

- 'child-displacement-x' (integer : default 0 : readable / private)

  How far in the x direction to move the child when the button is depressed

- 'child-displacement-y' (integer : default 0 : readable / private)

  How far in the y direction to move the child when the button is depressed

- 'default-border' (Gtk2::Border : default undef : readable / private)

  Extra space to add for GTK\_CAN\_DEFAULT buttons

- 'default-outside-border' (Gtk2::Border : default undef : readable / private)

  Extra space to add for GTK\_CAN\_DEFAULT buttons that is always drawn outside the border

- 'displace-focus' (boolean : default false : readable / private)

  Whether the child\_displacement\_x/\_y properties should also affect the focus rectangle

- 'image-spacing' (integer : default 2 : readable / private)

  Spacing in pixels between the image and label

- 'inner-border' (Gtk2::Border : default undef : readable / private)

  Border between button edges and child.

## SIGNALS

- **activate** (Gtk2::Button)

  - **clicked** (Gtk2::Button)

  - **enter** (Gtk2::Button)

  - **leave** (Gtk2::Button)

  - **pressed** (Gtk2::Button)

  - **released** (Gtk2::Button)

  ## ENUMS AND FLAGS

### enum Gtk2::PositionType

- •

  'left' / 'GTK\_POS\_LEFT'

- •

  'right' / 'GTK\_POS\_RIGHT'

- •

  'top' / 'GTK\_POS\_TOP'

- •

  'bottom' / 'GTK\_POS\_BOTTOM'

### enum Gtk2::ReliefStyle

- •

  'normal' / 'GTK\_RELIEF\_NORMAL'

- •

  'half' / 'GTK\_RELIEF\_HALF'

- •

  'none' / 'GTK\_RELIEF\_NONE'

## SEE ALSO

Gtk2, Glib::Object, Glib::InitiallyUnowned, Gtk2::Object, Gtk2::Widget, Gtk2::Container, Gtk2::Bin

## COPYRIGHT

Copyright (C) 2003-2011 by the gtk2-perl team.

This software is licensed under the LGPL.  See Gtk2 for a full notice.
