Spinner

The Spinner widget is used to show activity in progress. Usually, the Spinner is used when it is not known how long the action may take. A common example of its use is to indicate the loading of a web page.

Constructor

The Spinner can be constructed using:

spinner = Gtk.Spinner()

Methods

The two methods which allow starting and stopping of the Spinner are:

spinner.start()
spinner.stop()

Properties

To check whether the Spinner is active, the property call is:

active = spinner.get_property("active")

If the Spinner is running, True is returned.

Whether the Spinner is running or not is able to be set using:

spinner.set_property("active", active)

When active is set to True, the Spinner animation begins.

Examples

Below is an example of a Spinner:

#!/usr/bin/env python3

from gi.repository import Gtk

class Spinner(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self)
        self.set_default_size(200, 200)
        self.connect("destroy", Gtk.main_quit)

        grid = Gtk.Grid()
        grid.set_row_spacing(5)
        grid.set_column_spacing(5)
        self.add(grid)

        self.spinner = Gtk.Spinner()
        self.spinner.set_vexpand(True)
        self.spinner.set_hexpand(True)
        grid.attach(self.spinner, 0, 0, 2, 1)

        buttonStart = Gtk.Button("Start")
        buttonStart.connect("clicked", self.on_start_clicked)
        grid.attach(buttonStart, 0, 1, 1, 1)

        buttonStop = Gtk.Button("Stop")
        buttonStop.connect("clicked", self.on_stop_clicked)
        grid.attach(buttonStop, 1, 1, 1, 1)

    def on_start_clicked(self, button):
        self.spinner.start()

    def on_stop_clicked(self, button):
        self.spinner.stop()

window = Spinner()
window.show_all()

Gtk.main()

Download: Spinner