Create  Edit  FrontPage  Index  Search  Changes  History  RSS  Login

Gtk::SpinButton

class Gtk::SpinButton

A Gtk::SpinButton is an ideal way to allow the user to set the value of some attribute. Rather than having to directly type a number into a Gtk::Entry, Gtk::SpinButton allows the user to click on one of two arrows to increment or decrement the displayed value. A value can still be typed in, with the bonus that it can be checked to ensure it is in a given range.

The main properties of a Gtk::SpinButton are through a Gtk::Adjustment. See the Gtk::Adjustment section for more details about an adjustment's properties.

Class Methods

Gtk::SpinButton.new
Creates a new Gtk::SpinButton.
  • Returns: The new spin button.
Gtk::SpinButton.new(adjustment, climb_rate, digits)
Creates a new Gtk::SpinButton with Gtk::Adjustment.
  • adjustment: the Gtk::Adjustment object that this spin button should use.
  • climb_rate: specifies how much the spin button changes when an arrow is clicked on.(Float)
  • digits: the number of decimal places to display. (Integer)
  • Returns: The new spin button.
Gtk::SpinButton.new(min, max, step)
This is a convenience constructor that allows creation of a numeric Gtk::SpinButton without manually creating an adjustment. The value is initially set to the minimum value and a page increment of 10 * step is the default. The precision of the spin button is equivalent to the precision of step.
  • min: Minimum allowable value(Float)
  • max: Maximum allowable value(Float)
  • step: Increment added or subtracted by spinning the widget(Float)
  • Returns: The new spin button.

Instance Methods

configure(adjustment, climb_rate, digits)
Changes the properties of an existing spin button. The adjustment, climb rate, and number of decimal places are all changed accordingly, after this function call.
  • adjustment: a GtkAdjustment.
  • climb_rate: the new climb rate.
  • digits: the number of decimal places to display in the spin button.
  • Returns: self
adjustment
Get the adjustment associated with a Gtk::SpinButton
  • Returns : the GtkAdjustment of spin_button
adjustment=(adjustment)
Replaces the Gtk::Adjustment associated with spin_button.
  • adjustment: a Gtk::Adjustment to replace the existing adjustment
  • Returns: adjustment
set_adjustment(adjustment)
Same as Gtk::SpinButton#adjustment=.
  • adjustment: a Gtk::Adjustment to replace the existing adjustment
  • Returns: self
climb_rate
Gets the value which specifies how much the spin button changes when an arrow is clicked on.
  • Returns: the value specifies how much the spin button changes when an arrow is clicked on.(Float)
climb_rate=(climb_rate)
Sets the value which specifies how much the spin button changes when an arrow is clicked on.
  • climb_rate: specifies how much the spin button changes when an arrow is clicked on.(Float)
  • Returns: climb_rate
set_climb_rate(climb_rate)
Same as Gtk::SpinButton#climb_rate=.
  • climb_rate: specifies how much the spin button changes when an arrow is clicked on.(Float)
  • Returns: self
digits
Fetches the precision of spin_button. See Gtk::SpinButton#digits=.
  • Returns: the current precision
digits=(digits)
Set the precision to be displayed by spin_button. Up to 20 digit precision is allowed.
  • digits: the number of digits to be displayed for the spin button's value
  • Returns: digits
set_digits(digits)
Same as Gtk::SpinButton#digits=.
  • digits: the number of digits to be displayed for the spin button's value
  • Returns: self
increments
Gets the current step and page the increments used by spin_button. See Gtk::SpinButton#set_increments().
  • Returns: [step, page]
    • step: location to store step increment or nil
    • page: location to store page increment or nil
set_increments(step, page)
Sets the step and page increments for spin_button. This affects how quickly the value changes when the spin button's arrows are activated.
  • step: increment applied for a button 1 press. (Float)
  • page: increment applied for a button 2 press. (Float)
  • Returns: self
numeric?
Returns whether non-numeric text can be typed into the spin button. See Gtk::SpinButton#numeric=.
  • Returns: true if only numeric text can be entered
numeric=(numeric)
Sets the flag that determines if non-numeric text can be typed into the spin button.
  • numeric : flag indicating if only numeric entry is allowed.
  • Returns: numeric
set_numeric(numeric)
Same as Gtk::SpinButton#numeric=.
  • numeric : true if only numeric entry is allowed.
  • Returns: self
range
Gets the range allowed for spin_button. See Gtk::SpinButton#set_range.
  • Returns: [min, max]
    • min: location to store minimum allowed value, or nil
    • max: location to store maximum allowed value, or nil
set_range(min, max)
Sets the minimum and maximum allowable values for spin_button
  • min : minimum allowable value (Float)
  • max : maximum allowable value (Float)
  • Returns: self
snap_to_ticks?
Returns whether the values are corrected to the nearest step. See Gtk::SpinButton#snap_to_ticks=.
  • Returns: true if values are snapped to the nearest step.
snap_to_ticks=(snap_to_ticks)
Sets the policy as to whether values are corrected to the nearest step increment when a spin button is activated after providing an invalid value.
  • snap_to_ticks : true if invalid values should be corrected.
  • Returns: snap_to_ticks
set_snap_to_ticks
Same as Gtk::SpinButton#snap_to_ticks=.
  • snap_to_ticks : true if invalid values should be corrected.
  • Returns: self
update
Manually force an update of the spin button.
update_policy
Gets the update behavior of a spin button. See Gtk::SpinButton#update_policy=.
update_policy=(policy)
Sets the update behavior of a spin button. This determines whether the spin button is always updated or only when a valid value is set.
set_update_policy(policy)
Same as Gtk::SpinButton#update_policy=.
value
Get the value in the spin_button.
  • Returns: the value of spin_button
value=(value)
Set the value of spin_button.
  • value: the new value(Float)
  • Returns: value
set_value(value)
Same as Gtk::SpinButton#value=.
  • value: the new value(Float)
  • Returns: self
value_as_int
Get the value spin_button represented as an integer.
  • Returns: the value of spin_button
spin(direction, increment)
Increment or decrement a spin button's value in a specified direction by a specified amount.
  • direction: a GtkSpinType indicating the direction to spin.
  • increment: step increment to apply in the specified direction.
  • Returns: self
wrap?
Returns whether the spin button's value wraps around to the opposite limit when the upper or lower limit of the range is exceeded. See Gtk::SpinButton#wrap=.
  • Returns: true if the spin button wraps around
wrap=(wrap)
Sets the flag that determines if a spin button value wraps around to the opposite limit when the upper or lower limit of the range is exceeded.
  • wrap: true if wrapping behavior is performed.
  • Returns: wrap
set_wrap
Same as Gtk::SpinButton#wrap=.
  • wrap: true if wrapping behavior is performed.
  • Returns: self
change_value
  • Returns: self: FIXME
copy_clipboard
See Gtk::Editable#copy_clipboard.
cut_clipboard
See Gtk::Editable#cut_clipboard.
delete_selection
See Gtk::Editable#delete_selection.
delete_text
See Gtk::Editable#delete_text.
editable=
See Gtk::Editable#editable=.
editable?
See Gtk::Editable#editable?.
editing_done
See Gtk::CellEditable#editing_done.
get_chars
See Gtk::Editable#get_chars.
insert_text
See Gtk::Editable#insert_text.
paste_clipboard
See Gtk::Editable#paste_clipboard.
position
See Gtk::Editable#position.
position=
See Gtk::Editable#position=.
ref_accessible
See Atk::Implementor#ref_accessible.
remove_widget
See Gtk::CellEditable#remove_widget.
select_region
See Gtk::Editable#select_region.
selection_bounds
See Gtk::Editable#selection_bounds.
set_editable
See Gtk::Editable#set_editable.
set_position
See Gtk::Editable#set_position.
start_editing
See Gtk::CellEditable#start_editing.
add_child
See Gtk::Buildable#add_child.
construct_child
See Gtk::Buildable#construct_child.
get_internal_child
See Gtk::Buildable#get_internal_child.
name
See Gtk::Buildable#name.
name=
See Gtk::Buildable#name=.
set_buildable_property
See Gtk::Buildable#set_buildable_property.
set_name
See Gtk::Buildable#set_name.
builder_name
See Gtk::Buildable#builder_name.
builder_name=
See Gtk::Buildable#builder_name=.
editing_canceled=
See Gtk::CellEditable#editing_canceled=.
editing_canceled?
See Gtk::CellEditable#editing_canceled?.
set_builder_name
See Gtk::Buildable#set_builder_name.
set_editing_canceled
See Gtk::CellEditable#set_editing_canceled.

Constants

GtkSpinButtonUpdatePolicy

UPDATE_ALWAYS
When refreshing your Gtk::SpinButton, the value is always displayed.
UPDATE_IF_VALID
When refreshing your Gtk::SpinButton, the value is only displayed if it is valid within the bounds of the spin button's Gtk::Adjustment.

GtkSpinType

STEP_FORWARD
This value spin a Gtk::SpinButton by the relevant values of the spin button's Gtk::Adjustment.
STEP_BACKWARD
This value spin a Gtk::SpinButton by the relevant values of the spin button's Gtk::Adjustment.
PAGE_FORWARD
This value spin a Gtk::SpinButton by the relevant values of the spin button's Gtk::Adjustment.
PAGE_BACKWARD
This value spin a Gtk::SpinButton by the relevant values of the spin button's Gtk::Adjustment.
HOME
HOME and END set the spin button's value to the minimum or maxmimum possible values, (set by it's Gtk::Adjustment), respectively.
END
HOME and END set the spin button's value to the minimum or maxmimum possible values, (set by it's Gtk::Adjustment), respectively.
USER_DEFINED
The programmer must specify the exact amount to spin the Gtk::SpinButton.

Properties

adjustment: Gtk::Adjustment (Read/Write)
The adjustment that holds the value of the spinbutton
climb-rate: Float (Read/Write)
The acceleration rate when you hold down a button
digits: Integer (Read/Write)
The number of decimal places to display
numeric: true or false (Read/Write)
Whether non-numeric characters should be ignored
snap-to-ticks: true or false (Read/Write)
Whether erroneous values are automatically changed to a spin button's nearest step increment
update-policy: Integer (Read/Write)
Whether the spin button should update always, or only when the value is legal
value: Float (Read/Write)
Reads the current value, or sets a new value
wrap: true or false (Read/Write)
Whether a spin button should wrap upon reaching its limits

Style Properties

shadow-type: Gtk::ShadowType (Read)
Style of bevel around the spin button

See Also