Import pygtk
Pygtk. Require ('2. 0 ')
Import GTK
Class imagesexample:
Def close_application (self, widget, event, Data = none ):
GTK. main_quit ()
Return false
Def button_clicked (self, widget, Data = none ):
Print "button % s clicked" % data
Def _ init _ (Self ):
Window = GTK. Window (GTK. window_toplevel)
Window. Connect ("delete_event", self. close_application)
Window. set_border_width (10)
Window. Show ()
Hbox = GTK. hbox ()
Hbox. Show ()
Window. Add (hbox)
Pixbufanim = GTK. gdk. pixbufanimation ("/tmp/goalie.gif ")
Image = GTK. Image ()
Image. set_from_animation (pixbufanim)
Image. Show ()
Button = GTK. Button ()
Button. Add (image)
Button. Show ()
Hbox. pack_start (button)
Button. Connect ("clicked", self. button_clicked, "1 ")
Image = GTK. Image ()
Image. set_from_file ("/tmp/apple-red.png ")
Image. Show ()
Button = GTK. Button ()
Button. Add (image)
Button. Show ()
Hbox. pack_start (button)
Button. Connect ("clicked", self. button_clicked, "2 ")
Image = GTK. Image ()
Image. set_from_file ("/tmp/chaos.jpg ")
Image. Show ()
Button = GTK. Button ()
Button. Add (image)
Button. Show ()
Hbox. pack_start (button)
Button. Connect ("clicked", self. button_clicked, "3 ")
Image = GTK. Image ()
Image. set_from_file ("/tmp/important. tif ")
Image. Show ()
Button = GTK. Button ()
Button. Add (image)
Button. Show ()
Hbox. pack_start (button)
Button. Connect ("clicked", self. button_clicked, "4 ")
Image = GTK. Image ()
Image. set_from_file ("/tmp/soccerball.jpg ")
Image. Show ()
Button = GTK. Button ()
Button. Add (image)
Button. Show ()
Hbox. pack_start (button)
Button. Connect ("clicked", self. button_clicked, "5 ")
Def main (Self ):
GTK. Main ()
Return 0
If _ name __= = "_ main __":
Image = imagesexample ()
Image. Main ()
Currently, pygtk is relatively simple.