From d3a922a2bd0033cba59a8ae9eed60761da16c028 Mon Sep 17 00:00:00 2001 From: Jon Dowland Date: Sat, 23 Feb 2008 12:50:40 +0000 Subject: [PATCH] each loop creates a new and packs it into the hbox --- tools/cleanroom/images.py | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/tools/cleanroom/images.py b/tools/cleanroom/images.py index 7aba8754..40d72d9d 100644 --- a/tools/cleanroom/images.py +++ b/tools/cleanroom/images.py @@ -12,10 +12,6 @@ class ImagesExample: gtk.main_quit() return False - # is invoked when the button is clicked. It just prints a message. - def button_clicked(self, widget, data=None): - print "button %s clicked" % data - def __init__(self): # create the main window, and attach delete_event signal to terminating # the application @@ -31,30 +27,32 @@ class ImagesExample: # create several images with data from files and load images into # buttons - image = gtk.Image() - image.set_from_file("../../patches/wall40_1.gif") - pixbuf = image.get_pixbuf() + baseimage = gtk.Image() + baseimage.set_from_file("../../patches/wall40_1.gif") + pixbuf = baseimage.get_pixbuf() if pixbuf: scale = 2 - image.set_from_pixbuf(pixbuf.scale_simple( + baseimage.set_from_pixbuf(pixbuf.scale_simple( pixbuf.get_width() * scale, pixbuf.get_height() * scale, gtk.gdk.INTERP_NEAREST )) - image.show() + baseimage.show() - - image2 = gtk.Image() - image2.set_from_file("../../patches/wall42_3.gif") - pb = image2.get_pixbuf() - image2.set_from_pixbuf(pb.scale_simple( + basepatch = gtk.Image() + basepatch.set_from_file("../../patches/wall42_3.gif") + pb = basepatch.get_pixbuf() + basepatch.set_from_pixbuf(pb.scale_simple( pb.get_width() * scale, pb.get_height() * scale, gtk.gdk.INTERP_NEAREST )) - pb = image2.get_pixbuf() + pb = basepatch.get_pixbuf() for (x,y) in [(0,0), (51,0), (104,0)]: + image = gtk.Image() + image.set_from_pixbuf(baseimage.get_pixbuf().copy()) + image.show() pb.composite( image.get_pixbuf(), x * scale, y * scale, @@ -64,12 +62,11 @@ class ImagesExample: gtk.gdk.INTERP_NEAREST, 255 ) - # a button to contain the image widget - button = gtk.Button() - button.add(image) - button.show() - hbox.pack_start(button) - button.connect("clicked", self.button_clicked, "2") + # a button to contain the image widget + button = gtk.Button() + button.add(image) + button.show() + hbox.pack_start(button) def main(): gtk.main()