Gtk2::Button(3)
π Gtk2::Button β the wrapper for GtkButton π
okay bestie, sit down, hydrate, because today we're talking about Gtk2::Button β the Perl wrapper for GtkButton. It's the thing you click. It's the moment. It's the button. Periodt. π
This page lives in the User Contributed Perl Documentation section, and I'm about to give you the whole tour, no skips, no cuts, full album. π¦
πΈ HIERARCHY πΈ
so like, the ancestry?? immaculate. generational talent. look at this lineage:
Glib::Object
+----Glib::InitiallyUnowned
+----Gtk2::Object
+----Gtk2::Widget
+----Gtk2::Container
+----Gtk2::Bin
+----Gtk2::Button
six levels of main character energy and the button is the final form π
β¨ INTERFACES β¨
these are the interfaces it implements, and yes it's giving versatile:
Glib::Object::_Unregistered::AtkImplementorIface
Gtk2::Buildable
Gtk2::Activatable
π MNEMONICS π
okay so "mnemonics" is just fancy speak for memory aids. in GTK+, a mnemonic is an underlined character that maps to a keyboard accelerator. for a button, that means: hold Alt + press that key β button gets activated. keyboard girlies stay winning. β¨οΈ
for convenience, Gtk2-Perl uses mnemonics by default on widgets that support them. if characters in the label string are preceded by an underscore, they get underlined. and listen β if you need a literal underscore character in a label, use '__' (two underscores, bestie, two). if you don't want mnemonics at all, just use the non-mnemonic version explicitly (e.g. Gtk2::Button::new_with_label). pick your fighter. π«Ά
π₯ METHODS π₯
widget = Gtk2::Button->new
widget = Gtk2::Button->new ($mnemonic)
$mnemonic(string) β used to label the widget, see "MNEMONICS" above π
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: defaulttrue: readable / writable / private / static-nick / static-blurb) β Whether the button grabs focus when it is clicked with the mouse'image'(Gtk2::Widget: defaultundef: readable / writable / private / static-nick / static-blurb) β Child widget to appear next to the button text'image-position'(Gtk2::PositionType: default"left": readable / writable / private / static-nick / static-blurb) β The position of the image relative to the text'label'(string: defaultundef: readable / writable / construct / private / static-nick / static-blurb) β Text of the label widget inside the button, if the button contains a label widget'relief'(Gtk2::ReliefStyle: default"normal": readable / writable / private / static-nick / static-blurb) β The border relief style'use-stock'(boolean: defaultfalse: readable / writable / construct / private / static-nick / static-blurb) β If set, the label is used to pick a stock item instead of being displayed'use-underline'(boolean: defaultfalse: readable / writable / construct / private / static-nick / static-blurb) β If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key'xalign'(float: default0.5: readable / writable / private / static-nick / static-blurb) β Horizontal position of child in available space.0.0is left aligned,1.0is right aligned'yalign'(float: default0.5: readable / writable / private / static-nick / static-blurb) β Vertical position of child in available space.0.0is top aligned,1.0is bottom aligned
π STYLE PROPERTIES π
'child-displacement-x'(integer: default0: readable / private / static-nick / static-blurb) β How far in the x direction to move the child when the button is depressed'child-displacement-y'(integer: default0: readable / private / static-nick / static-blurb) β How far in the y direction to move the child when the button is depressed'default-border'(Gtk2::Border: defaultundef: readable / private / static-nick / static-blurb) β Extra space to add forGTK_CAN_DEFAULTbuttons'default-outside-border'(Gtk2::Border: defaultundef: readable / private / static-nick / static-blurb) β Extra space to add forGTK_CAN_DEFAULTbuttons that is always drawn outside the border'displace-focus'(boolean: defaultfalse: readable / private / static-nick / static-blurb) β Whether thechild_displacement_x/_yproperties should also affect the focus rectangle'image-spacing'(integer: default2: readable / private / static-nick / static-blurb) β Spacing in pixels between the image and label'inner-border'(Gtk2::Border: defaultundef: readable / private / static-nick / static-blurb) β 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.
and that's the whole page, bestie π this was perl v5.42.0, dated 2025-07-25, and yes β Gtk2::Button(3) ate and left no crumbs. go click something iconic. πβ¨
π¦ where this page comes from
- fedora 43: perl-Gtk2 1.24993-23.fc43 Β· LicenseRef-Callaway-LGPLv2+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms