Advertisement
metalx1000

Create a GTK Window with a Clickable Image

Apr 11th, 2013
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import gtk
  4.  
  5. def img_click(self, widget):
  6.     print "You Clicked an Image"
  7.  
  8. win = gtk.Window()
  9. box = gtk.VBox()
  10. win.add(box)
  11. event_box = gtk.EventBox()
  12. event_box.set_events(gtk.gdk.BUTTON_PRESS_MASK)
  13. event_box.connect("button_press_event", img_click)
  14. box.pack_start(event_box)
  15.  
  16. img=gtk.Image()
  17. img.set_from_file("1.png")
  18. event_box.add(img)
  19.  
  20.  
  21. win.show_all()
  22.  
  23. gtk.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement