Skip to content
Related Articles

Related Articles

Improve Article

Python – Spinner in GTK+ 3

  • Last Updated : 29 Aug, 2020

The Gtk.Spinner displays an icon-size spinning animation. It is often used as an alternative to a GtkProgressBar for displaying an indefinite activity. We can use Gtk.Spinner.start() to start and Gtk.Spinner.stop() to stop the animation.

Example :


import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
class SpinnerAnimation(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self, title="GFG")
        self.connect("destroy", Gtk.main_quit)
        self.button = Gtk.ToggleButton(label="Start Spinning")
        self.button.connect("toggled", self.on_button_toggled)
        self.spinner = Gtk.Spinner()
        self.grid = Gtk.Grid()
            self.spinner, self.button, Gtk.PositionType.BOTTOM, 1, 2
    def on_button_toggled(self, button):
        if button.get_active():
            self.button.set_label("Stop Spinning")
            self.button.set_label("Start Spinning")
myspinner = SpinnerAnimation()

Output :

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :