File: simple.py

package info (click to toggle)
kiwi 1.9.22-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 11,908 kB
  • ctags: 5,549
  • sloc: python: 15,779; ansic: 193; xml: 77; makefile: 57; sh: 17
file content (35 lines) | stat: -rw-r--r-- 1,000 bytes parent folder | download | duplicates (3)
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
33
34
35
#!/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()