diff options
author | John Stowers <john.stowers@gmail.com> | 2010-07-09 13:43:11 +1200 |
---|---|---|
committer | John Stowers <john.stowers@gmail.com> | 2010-07-09 15:25:42 +1200 |
commit | 088ff0490a0fa05a31c4840dad189c913e7ab91b (patch) | |
tree | b8933c65daddf79c8b8bf2c4763c7daafb66d645 /examples/pygtk-demo/demos/spinner.py | |
parent | 6d6e8b0864c5ac6470e258d20edd09a0fd07952a (diff) | |
download | pygtk-088ff0490a0fa05a31c4840dad189c913e7ab91b.tar.gz |
Add new Gtk-2.20 API
* Notably this adds GtkSpinner, GtkOffscreenWindow,
GtkCellRendererSpinner, GtkToolPalette objects
* Add new api to other objects
* Add gtk.ToolbarPalette demo
* Add gtk.Spinner demo
Diffstat (limited to 'examples/pygtk-demo/demos/spinner.py')
-rw-r--r-- | examples/pygtk-demo/demos/spinner.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/examples/pygtk-demo/demos/spinner.py b/examples/pygtk-demo/demos/spinner.py new file mode 100644 index 00000000..10111863 --- /dev/null +++ b/examples/pygtk-demo/demos/spinner.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python +"""Spinner + +GtkSpinner allows to show that background activity is on-going. +""" +# pygtk version: John Stowers <john.stowers@gmail.com> + +import gtk + +class SpinnerDemo(gtk.Window): + def __init__(self, parent=None): + gtk.Window.__init__(self) + try: + self.set_screen(parent.get_screen()) + except AttributeError: + self.connect('destroy', lambda *w: gtk.main_quit()) + self.set_title(self.__class__.__name__) + self.set_border_width(5) + + vb = gtk.VBox(spacing=5) + self.add(vb) + + #sensitive + hb = gtk.HBox(spacing=5) + self.ss = gtk.Spinner() + hb.add(self.ss) + hb.add(gtk.Entry()) + vb.add(hb) + + #unsensitive + hb = gtk.HBox(spacing=5) + self.us = gtk.Spinner() + hb.add(self.us) + hb.add(gtk.Entry()) + hb.set_sensitive(False) + vb.add(hb) + + b = gtk.Button(stock=gtk.STOCK_MEDIA_PLAY) + b.connect("clicked", self._on_play_clicked) + vb.add(b) + + b = gtk.Button(stock=gtk.STOCK_MEDIA_STOP) + b.connect("clicked", self._on_stop_clicked) + vb.add(b) + + self._on_play_clicked(None) + + self.show_all() + + def _on_play_clicked(self, b): + self.ss.start() + self.us.start() + + def _on_stop_clicked(self, b): + self.ss.stop() + self.us.stop() + +def main(): + SpinnerDemo() + gtk.main() + +if __name__ == '__main__': + main() |