each loop creates a new and packs it into the hbox

This commit is contained in:
Jon Dowland 2008-02-23 12:50:40 +00:00
parent ede6852539
commit d3a922a2bd

View file

@ -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()