import pygtk
pygtk.require('2.0')
import gtk
import random
greetings = ["Goodbye Cruel World", "I'm Leaving You Today",
"Goodbye, Goodbye, Goodbye"]
def select_greeting (greet):
return greet[random.randint(0, len(greet)-1)]
def hello_button_clicked(button, label):
label.set_text(select_greeting(greetings))
window = gtk.Window ()
vbox = gtk.VBox ()
button = gtk.Button("Welcome to the Machine")
label = gtk.Label (choose_greeting (greetings))
window.add(vbox)
vbox.add(label)
vbox.pack_start(button, False, False)
window.connect("delete-event", lambda a,b: gtk.main_quit())
button.connect("clicked", hello_button_clicked, label)
window.show_all()
gtk.main()
|