1 #!/usr/bin/python 2 3 import gtk 4 5 def do_exit (window): # this is a signal handler 6 gtk.main_quit () # - we want to stop the main loop 7 8 window = gtk.Window () # create a "Window" widget 9 label = gtk.Label ("Hello World") # create a "Label" widget 10 11 window.add (label) # pack the Label in the Window 12 13 window.connect ("destroy", do_exit) # handle the "destroy" signal with the 14 # do_exit() call 15 16 window.show_all () # put all widgets in the tree into the 17 # show state 18 19 gtk.main () # start the main loop