Gtk2::SpinButton(3)

πŸ“¦
version 1.24993 Β· 2 versions
, in fedora 43

πŸ’– 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 (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