Skip to content
Ebru Akagündüz edited this page May 3, 2015 · 1 revision

Spinner button is an alternative to show activity mode, it has better view. You can start and stop spinning.

require "gtk3"

class SpinnerAnimation < Gtk::Window

  def initialize
    super
    set_title("SpinnerButton Demo")
    set_border_width(10)
    button = Gtk::ToggleButton.new("Start Spinning")
    button.signal_connect("toggled") {|button| on_button_toggled(button)}
    button.set_active(false)

    @spinner = Gtk::Spinner.new
    table = Gtk::Table.new(3, 2, true)
    table.attach(button, 0, 2, 0, 1)
    table.attach(@spinner, 0, 2, 2, 3)

    add(table)
    show_all
  end

  def on_button_toggled(button)
    if button.active?
      @spinner.start
      button.set_label("Stop Spinning")
    else
      @spinner.stop
      button.set_label("Start Spinning")
    end
  end
end

spinner = SpinnerAnimation.new
Gtk.main
Clone this wiki locally