Gtk2::SpinButton(3)
π Gtk2::SpinButton π
okay bestie so like. <pink>Gtk2::SpinButton</pink> is a wrapper for <pink>GtkSpinButton</pink>. that's the whole name section, we ate that. and yes this is from the User Contributed Perl Documentation collection, so you know it's the people's manpage π
it's the little number field with the up/down arrows that goes click click click and honestly? iconic behavior. the main character of every "how many widgets do you want" dialog. let's get into it β¨
πΈ HIERARCHY πΈ
the family tree, and she comes from a LONG line of distinguished ancestors, no cap:
Glib::Object
+----Glib::InitiallyUnowned
+----Gtk2::Object
+----Gtk2::Widget
+----Gtk2::Entry
+----Gtk2::SpinButton
so like she IS an Entry, she just also has β¨opinionsβ¨ about numbers. nepo baby but make it useful π
π¦ INTERFACES π¦
she also implements these, because she's multi-talented and does it all:
Glib::Object::_Unregistered::AtkImplementorIface
Gtk2::Buildable
Gtk2::Editable
Gtk2::CellEditable
β¨ METHODS β¨
okay here's where it gets good. every single one, let's go π«Ά
π widget = Gtk2::SpinButton->new ($adjustment, $climb_rate, $digits)
the classic constructor. make a fresh spin button, bestie.
$adjustment(Gtk2::Adjustment) β the adjustment object holding the value$climb_rate(double) β how fast it accelerates when you hold the button down$digits(integer) β how many decimal places to show
π widget = Gtk2::SpinButton->new_with_range ($min, $max, $step)
the shortcut constructor, literally the "just give me a range and go" option. lowkey the one you'll use most:
$min(double)$max(double)$step(double)
π adjustment = $spin_button->get_adjustment
π $spin_button->set_adjustment ($adjustment)
$adjustment(Gtk2::Adjustment)
grab or swap out the adjustment, which is the thing that actually holds the value. she's just the pretty face, the adjustment is doing the math behind the scenes π§
π $spin_button->configure ($adjustment, $climb_rate, $digits)
set a whole bunch of stuff in one go. efficiency queen.
$adjustment(Gtk2::Adjustment)$climb_rate(double)$digits(integer)
β integer = $spin_button->get_digits
β $spin_button->set_digits ($digits)
$digits(integer)
decimal places. get them, set them, slay.
π¦ (step, page) = $spin_button->get_increments
π¦ $spin_button->set_increments ($step, $page)
$step(double)$page(double)
how far one little nudge moves you, vs. how far a big jump moves you.
π
boolean = $spin_button->get_numeric
π
$spin_button->set_numeric ($numeric)
$numeric(boolean)
turn this on and non-numeric characters get ignored. no letters allowed in the number box, sorry not sorry π
πΈ (min, max) = $spin_button->get_range
πΈ $spin_button->set_range ($min, $max)
$min(double)$max(double)
the boundaries. she has them, and honestly? boundaries are healthy.
π₯ boolean = $spin_button->get_snap_to_ticks
π₯ $spin_button->set_snap_to_ticks ($snap_to_ticks)
$snap_to_ticks(boolean)
on = erroneous values get auto-corrected to the nearest step increment. she does not tolerate your sloppy typing, she snaps it into place.
π $spin_button->spin ($direction, $increment)
make it spin, bestie!! π
$direction(Gtk2::SpinType)$increment(double)
β¨ $spin_button->update
just... update it. do the thing. periodt.
π spinbuttonupdatepolicy = $spin_button->get_update_policy
π $spin_button->set_update_policy ($policy)
$policy(Gtk2::SpinButtonUpdatePolicy)
controls whether she updates always or only when the value is legal. her vibe, her rules.
π integer = $spin_button->get_value_as_int
the value, but make it an integer. no decimals, just vibes.
π double = $spin_button->get_value
π $spin_button->set_value ($value)
$value(double)
the actual number. the whole point. get it, set it, obsessed.
π§ boolean = $spin_button->get_wrap
π§ $spin_button->set_wrap ($wrap)
$wrap(boolean)
if true, she wraps around when she hits her limits instead of just giving up. resilience queen π
π PROPERTIES π
these are all <yellow>readable / writable / private / static-nick / static-blurb</yellow> unless noted, and y'all know what that means β go off, set them:
'adjustment'(Gtk2::Adjustment : default undef : readable / writable / private / static-nick / static-blurb) β the adjustment that holds the value of the spinbutton'climb-rate'(double : default 0 : readable / writable / private / static-nick / static-blurb) β the acceleration rate when you hold down a button'digits'(Glib::UInt : default 0 : readable / writable / private / static-nick / static-blurb) β the number of decimal places to display'numeric'(boolean : default false : readable / writable / private / static-nick / static-blurb) β whether non-numeric characters should be ignored'snap-to-ticks'(boolean : default false : readable / writable / private / static-nick / static-blurb) β whether erroneous values are automatically changed to a spin button's nearest step increment'update-policy'(Gtk2::SpinButtonUpdatePolicy : default "always" : readable / writable / private / static-nick / static-blurb) β whether the spin button should update always, or only when the value is legal'value'(double : default 0 : readable / writable / private / static-nick / static-blurb) β reads the current value, or sets a new value'wrap'(boolean : default false : readable / writable / private / static-nick / static-blurb) β whether a spin button should wrap upon reaching its limits
π STYLE PROPERTIES π
just the one, and she's giving subtle:
'shadow-type'(Gtk2::ShadowType : default "in" : readable / private / static-nick / static-blurb) β style of bevel around the spin button
note bestie: this one is <red>readable / private</red> β no writable, so look but don't touch π
π₯ SIGNALS π₯
when she's feeling something, she lets you know:
change-value(Gtk2::SpinButton, Gtk2::ScrollType)- integer =
input(Gtk2::SpinButton, gpointer) - boolean =
output(Gtk2::SpinButton) value-changed(Gtk2::SpinButton)wrapped(Gtk2::SpinButton)
π ENUMS AND FLAGS π
the lore. the vocabulary. iykyk.
π« enum Gtk2::ScrollType
'none'/GTK_SCROLL_NONE'jump'/GTK_SCROLL_JUMP'step-backward'/GTK_SCROLL_STEP_BACKWARD'step-forward'/GTK_SCROLL_STEP_FORWARD'page-backward'/GTK_SCROLL_PAGE_BACKWARD'page-forward'/GTK_SCROLL_PAGE_FORWARD'step-up'/GTK_SCROLL_STEP_UP'step-down'/GTK_SCROLL_STEP_DOWN'page-up'/GTK_SCROLL_PAGE_UP'page-down'/GTK_SCROLL_PAGE_DOWN'step-left'/GTK_SCROLL_STEP_LEFT'step-right'/GTK_SCROLL_STEP_RIGHT'page-left'/GTK_SCROLL_PAGE_LEFT'page-right'/GTK_SCROLL_PAGE_RIGHT'start'/GTK_SCROLL_START'end'/GTK_SCROLL_END
π« enum Gtk2::SpinButtonUpdatePolicy
'always'/GTK_UPDATE_ALWAYS'if-valid'/GTK_UPDATE_IF_VALID
π« enum Gtk2::SpinType
'step-forward'/GTK_SPIN_STEP_FORWARD'step-backward'/GTK_SPIN_STEP_BACKWARD'page-forward'/GTK_SPIN_PAGE_FORWARD'page-backward'/GTK_SPIN_PAGE_BACKWARD'home'/GTK_SPIN_HOME'end'/GTK_SPIN_END'user-defined'/GTK_SPIN_USER_DEFINED
π SEE ALSO π
go read these too, they're all in the group chat:
Gtk2, Glib::Object, Glib::InitiallyUnowned, Gtk2::Object, Gtk2::Widget, Gtk2::Entry
π COPYRIGHT π
Copyright (C) 2003-2011 by the gtk2-perl team.
This software is licensed under the LGPL. See Gtk2 for a full notice.
okay that's the whole page bestie, you're officially a spin button expert π
β¨ this was brought to you by perl v5.42.0 and dated 2025-07-25, so like. shoutout to that exact moment in time for preserving all this for us π«Ά mwah, go forth and spin ππ
π¦ 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