Back to Seed Clases

Gtk


Classes

Interfaces

Structs

Unions

Enums

Class Gtk.SpinButton

Import line: Gtk = imports.gi.Gtk;
GIR File: Gtk-3.0.gir
C documentation: GtkSpinButton
Class : SpinButton
Implements: Atk.ImplementorIface, Gtk.Buildable, Gtk.CellEditable, Gtk.Editable
Extends: Gtk.Entry
A GtkSpinButton 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
GtkEntry, GtkSpinButton 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 GtkSpinButton are through an adjustment.
See the GtkAdjustment section for more details about an adjustment's
properties.

Using a GtkSpinButton to get an integer

/* Provides a function to retrieve an integer value from a
* GtkSpinButton and creates a spin button to model percentage
* values.
*/
gint
grab_int_value (GtkSpinButton *button,
gpointer user_data)
{
return gtk_spin_button_get_value_as_int (button);
}
void
create_integer_spin_button (void)
{
GtkWidget *window, *button;
GtkAdjustment *adjustment;
adjustment = gtk_adjustment_new (50.0, 0.0, 100.0, 1.0, 5.0, 0.0);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width (GTK_CONTAINER (window), 5);
/* creates the spinbutton, with no decimal places */
button = gtk_spin_button_new (adjustment, 1.0, 0);
gtk_container_add (GTK_CONTAINER (window), button);
gtk_widget_show_all (window);
}



Using a GtkSpinButton to get a floating point value

/* Provides a function to retrieve a floating point value from a
* GtkSpinButton, and creates a high precision spin button.
*/
gfloat
grab_float_value (GtkSpinButton *button,
gpointer user_data)
{
return gtk_spin_button_get_value (button);
}
void
create_floating_spin_button (void)
{
GtkWidget *window, *button;
GtkAdjustment *adjustment;
adjustment = gtk_adjustment_new (2.500, 0.0, 5.0, 0.001, 0.1, 0.0);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width (GTK_CONTAINER (window), 5);
/* creates the spinbutton, with three decimal places */
button = gtk_spin_button_new (adjustment, 0.001, 3);
gtk_container_add (GTK_CONTAINER (window), button);
gtk_widget_show_all (window);
}

Properties
Properties Defined By
Methods / Constructors
Method / Constructor Defined By
Events - usage syntax: this.signals.EVENTNAME.connect( Function )
Event Defined By
Used by These Methods / Signals / Properties
Class / Namespace Method / Signal / Properties
Gtk
Method
Gtk.test_spin_button_click (SpinButton spinner, guint32 button, gboolean upwards) : gboolean
This function will generate a button click in the upwards or downwards
spin button arrow areas, usually leading to an increase or decrease of
spin button's value.
Documentation generated by Introspection Doc Generator Loosely Based on JsDoc Toolkit on Sat Apr 16 2011 17:13:54 GMT+0800 (HKT)