Showing changes from revision #4 to #5:
Added | Removed
El control Spin Button (Botón Aumentar/ Disminuir) se usa generalmente para permitir al usuario seleccionar un valor dentro de un rango de valores numéricos tarjetas de visita. Consiste en una caja de entrada de texto con botones de flecha arriba y abajo a un lado. Seleccionando uno de los botones causa que el valor aumente o disminuya en el rango de valores posibles. La caja de entrada también puede editarse directamente para introducir un valor específico.
El Spin Button permite que el valor tenga cero o más cifras decimales y puede incrementarse/decrementarse en pasos configurables. La acción de mantener pulsado uno de los botones opcionalmente provoca una aceleración en el cambio del valor correspondiente al tiempo que se mantenga presionado.
El Spin Button usa un objeto Adjustment (Ajuste) para almacenar la información del rango de valores que el botón aumentar/disminuir puede tomar. Esto le hace un control muy útil.
El siguiente programa (como el texto de arriba) está sacado de una essays web de python, lo que hice fue migrarlos a Ruby.

require 'gtk2' class SpinButtonExample def toggle_snap(widget, spin) spin.set_snap_to_ticks(widget.active?) end def toggle_numeric(widget, spin) spin.set_numeric(widget.active?) end def change_digits(widget, spin, spin1) spin1.set_digits(spin.value.to_i) end def get_value(widget, data, spin, spin2, label) if data == 1 buf = spin.value.to_i.to_s else buf = sprintf("%0.*f", spin2.value.to_i, spin.value) end label.set_text(buf) end def initialize window = Gtk::Window.new(Gtk::Window::TOPLEVEL) window.signal_connect("destroy"){Gtk::main_quit()} window.set_title("Spin Button") main_vbox = Gtk::VBox.new(false, 5) main_vbox.set_border_width(10) window.add(main_vbox) frame = Gtk::Frame.new("Not accelerated") main_vbox.pack_start(frame, true, true, 0) vbox = Gtk::VBox.new(false, 0) vbox.set_border_width(5) frame.add(vbox) # Day, month, year spinners hbox = Gtk::HBox.new(false, 0) vbox.pack_start(hbox, true, true, 5) vbox2 = Gtk::VBox.new(false, 0) hbox.pack_start(vbox2, true, true, 5) label = Gtk::Label.new("Day :") label.set_alignment(0, 0.5) vbox2.pack_start(label, false, true, 0) adj = Gtk::Adjustment.new(1.0, 1.0, 31.0, 1.0, 5.0, 0.0) spinner = Gtk::SpinButton.new(adj, 0, 0) spinner.set_wrap(true) vbox2.pack_start(spinner, false, true, 0) vbox2 = Gtk::VBox.new(false, 0) hbox.pack_start(vbox2, true, true, 5) label = Gtk::Label.new("Month :") label.set_alignment(0, 0.5) vbox2.pack_start(label, false, true, 0) adj = Gtk::Adjustment.new(1.0, 1.0, 12.0, 1.0, 5.0, 0.0) spinner = Gtk::SpinButton.new(adj, 0, 0) spinner.set_wrap(true) vbox2.pack_start(spinner, false, true, 0) vbox2 = Gtk::VBox.new(false, 0) hbox.pack_start(vbox2, true, true, 5) label = Gtk::Label.new("Year :") label.set_alignment(0, 0.5) vbox2.pack_start(label, false, true, 0) adj = Gtk::Adjustment.new(1998.0, 0.0, 2100.0, 1.0, 100.0, 0.0) spinner = Gtk::SpinButton.new(adj, 0, 0) spinner.set_wrap(false) spinner.set_size_request(55, -1) vbox2.pack_start(spinner, false, true, 0) frame = Gtk::Frame.new("Accelerated") main_vbox.pack_start(frame, true, true, 0) vbox = Gtk::VBox.new(false, 0) vbox.set_border_width(5) frame.add(vbox) hbox = Gtk::HBox.new(false, 0) vbox.pack_start(hbox, false, true, 5) vbox2 = Gtk::VBox.new(false, 0) hbox.pack_start(vbox2, true, true, 5) label = Gtk::Label.new("Value :") label.set_alignment(0, 0.5) vbox2.pack_start(label, false, true, 0) adj = Gtk::Adjustment.new(0.0, -10000.0, 10000.0, 0.5, 100.0, 0.0) spinner1 = Gtk::SpinButton.new(adj, 1.0, 2) spinner1.set_wrap(true) spinner1.set_size_request(100, -1) vbox2.pack_start(spinner1, false, true, 0) vbox2 = Gtk::VBox.new(false, 0) hbox.pack_start(vbox2, true, true, 5) label = Gtk::Label.new("Digits :") label.set_alignment(0, 0.5) vbox2.pack_start(label, false, true, 0) adj = Gtk::Adjustment.new(2, 1, 5, 1, 1, 0) spinner2 = Gtk::SpinButton.new(adj, 0.0, 0) spinner2.set_wrap(true) adj.signal_connect("value_changed") {change_digits(adj, spinner2, spinner1)} vbox2.pack_start(spinner2, false, true, 0) hbox = Gtk::HBox.new(false, 0) vbox.pack_start(hbox, false, true, 5) button1 = Gtk::CheckButton.new("Snap to 0.5-ticks") button1.signal_connect("clicked"){toggle_snap(button1, spinner1)} vbox.pack_start(button1, true, true, 0) button1.set_active(true) button2 = Gtk::CheckButton.new("Numeric only input mode") button2.signal_connect("clicked"){ toggle_numeric(button2, spinner1) } vbox.pack_start(button2, true, true, 0) button2.set_active(true) val_label = Gtk::Label.new("") hbox = Gtk::HBox.new(false, 0) vbox.pack_start(hbox, false, true, 5) button = Gtk::Button.new("Value as Int") button.signal_connect("clicked"){ get_value(button, 1, spinner1, spinner2, val_label)} hbox.pack_start(button, true, true, 5) button = Gtk::Button.new("Value as Float") button.signal_connect("clicked") {get_value(button, 2, spinner1, spinner2, val_label)} hbox.pack_start(button, true, true, 5) vbox.pack_start(val_label, true, true, 0) val_label.set_text("0") hbox = Gtk::HBox.new(false, 0) main_vbox.pack_start(hbox, false, true, 0) button = Gtk::Button.new("Close") button.signal_connect("clicked") {Gtk::main_quit()} hbox.pack_start(button, true, true, 5) window.show_all() end end Gtk.init SpinButtonExample.new() Gtk.main()
pacquiao vs marquez Philippine Travel Travel Asia home ideas Fifa World Cup pacquiao vs marquez tickets donaire vs narvaez cotto vs margarito donaire vs narvaez ticketslancaster estate cavite
cotto vs margarito live streaming essay writing guide cotto vs margarito tickets st-pierre vs diaz st-pierre vs diaz tickets pacquiao vs marquez velasquez vs dos santos velasquez vs dos santos tickets