1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#!/usr/bin/env python
import gtk
from kiwi.ui.delegates import Delegate
class Hello(Delegate):
def __init__(self):
self.index = 0
self.text = ["I've decided to take my work back underground",
"To keep it from falling into the wrong hands."]
topwidget = gtk.Window()
topwidget.set_title("So...")
self.button = gtk.Button(self.text[self.index])
topwidget.add(self.button)
Delegate.__init__(self, topwidget, delete_handler=self.quit_if_last)
# focus button, our only widget
self.focus_topmost()
def on_button__clicked(self, button, *args):
self.index = self.index + 1
# Two clicks and we're gone
if self.index > 1:
self.hide_and_quit()
# the *handler's* return value disappears into GTK+
return
button.set_label(self.text[self.index])
app = Hello()
app.show_all()
gtk.main()
|