Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #18 from vaporup/master

Example for a spinner animation
  • Loading branch information...
commit c1da1378eb8e0c54bf5bda5748a52b1172f4de77 2 parents 937a5eb + e0d6fcf
Sebastian Pölsterl authored
39 examples/spinner_example.py
... ... @@ -0,0 +1,39 @@
  1 +
  2 +from gi.repository import Gtk
  3 +
  4 +class SpinnerAnimation(Gtk.Window):
  5 +
  6 + def __init__(self):
  7 +
  8 + Gtk.Window.__init__(self, title="Spinner")
  9 + self.set_border_width(3)
  10 + self.connect("delete-event", Gtk.main_quit)
  11 +
  12 + self.button = Gtk.ToggleButton("Start Spinning")
  13 + self.button.connect("toggled", self.on_button_toggled)
  14 + self.button.set_active(False)
  15 +
  16 + self.spinner = Gtk.Spinner()
  17 +
  18 + self.table = Gtk.Table(3, 2, True)
  19 + self.table.attach(self.button, 0, 2, 0, 1)
  20 + self.table.attach(self.spinner, 0, 2, 2, 3)
  21 +
  22 + self.add(self.table)
  23 + self.show_all()
  24 +
  25 + def on_button_toggled(self, button):
  26 +
  27 + if button.get_active():
  28 + self.spinner.start()
  29 + self.button.set_label("Stop Spinning")
  30 +
  31 + else:
  32 + self.spinner.stop()
  33 + self.button.set_label("Start Spinning")
  34 +
  35 +
  36 +myspinner = SpinnerAnimation()
  37 +
  38 +Gtk.main()
  39 +
BIN  images/spinner_example.png
1  source/index.txt
@@ -42,6 +42,7 @@ Contents:
42 42 entry
43 43 button_widgets
44 44 progressbar
  45 + spinner
45 46 treeview
46 47 cellrenderers
47 48 combobox
30 source/spinner.txt
... ... @@ -0,0 +1,30 @@
  1 +Spinner
  2 +=======
  3 +
  4 +The :class:`Gtk.Spinner` displays an icon-size spinning animation.
  5 +It is often used as an alternative to a :class:`GtkProgressBar`
  6 +for displaying indefinite activity, instead of actual progress.
  7 +
  8 +To start the animation, use :meth:`Gtk.Spinner.start`,
  9 +to stop it use :meth:`Gtk.Spinner.stop`.
  10 +
  11 +Spinner Objects
  12 +----------------
  13 +
  14 +.. class:: Gtk.Spinner()
  15 +
  16 + .. method:: start()
  17 +
  18 + Starts the animation of the spinner.
  19 +
  20 + .. method:: stop()
  21 +
  22 + Stops the animation of the spinner.
  23 +
  24 +Example
  25 +-------
  26 +
  27 +.. image:: ../images/spinner_example.png
  28 +
  29 +.. literalinclude:: ../examples/spinner_example.py
  30 + :linenos:

0 comments on commit c1da137

Please sign in to comment.
Something went wrong with that request. Please try again.