Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > 81476b1f7b3bd1e74b17495490537d1c > files > 48

python-kiwi-docs-1.9.38-3.mga4.x86_64.rpm

#!/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])
        self.button.show()
        topwidget.add(self.button)

        Delegate.__init__(self, topwidget, delete_handler=gtk.main_quit)
        # focus button, our only widget
        self.focus_topmost()

    def on_button__clicked(self, button):
        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

        # update the label of the button
        button.set_label(self.text[self.index])

app = Hello()
app.show_and_loop()