mirror of
https://github.com/freedoom/freedoom.git
synced 2025-09-02 07:25:45 -04:00
each loop creates a new and packs it into the hbox
This commit is contained in:
parent
ede6852539
commit
d3a922a2bd
1 changed files with 18 additions and 21 deletions
|
@ -12,10 +12,6 @@ class ImagesExample:
|
||||||
gtk.main_quit()
|
gtk.main_quit()
|
||||||
return False
|
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):
|
def __init__(self):
|
||||||
# create the main window, and attach delete_event signal to terminating
|
# create the main window, and attach delete_event signal to terminating
|
||||||
# the application
|
# the application
|
||||||
|
@ -31,30 +27,32 @@ class ImagesExample:
|
||||||
|
|
||||||
# create several images with data from files and load images into
|
# create several images with data from files and load images into
|
||||||
# buttons
|
# buttons
|
||||||
image = gtk.Image()
|
baseimage = gtk.Image()
|
||||||
image.set_from_file("../../patches/wall40_1.gif")
|
baseimage.set_from_file("../../patches/wall40_1.gif")
|
||||||
pixbuf = image.get_pixbuf()
|
pixbuf = baseimage.get_pixbuf()
|
||||||
if pixbuf:
|
if pixbuf:
|
||||||
scale = 2
|
scale = 2
|
||||||
image.set_from_pixbuf(pixbuf.scale_simple(
|
baseimage.set_from_pixbuf(pixbuf.scale_simple(
|
||||||
pixbuf.get_width() * scale,
|
pixbuf.get_width() * scale,
|
||||||
pixbuf.get_height() * scale,
|
pixbuf.get_height() * scale,
|
||||||
gtk.gdk.INTERP_NEAREST
|
gtk.gdk.INTERP_NEAREST
|
||||||
))
|
))
|
||||||
image.show()
|
baseimage.show()
|
||||||
|
|
||||||
|
basepatch = gtk.Image()
|
||||||
image2 = gtk.Image()
|
basepatch.set_from_file("../../patches/wall42_3.gif")
|
||||||
image2.set_from_file("../../patches/wall42_3.gif")
|
pb = basepatch.get_pixbuf()
|
||||||
pb = image2.get_pixbuf()
|
basepatch.set_from_pixbuf(pb.scale_simple(
|
||||||
image2.set_from_pixbuf(pb.scale_simple(
|
|
||||||
pb.get_width() * scale,
|
pb.get_width() * scale,
|
||||||
pb.get_height() * scale,
|
pb.get_height() * scale,
|
||||||
gtk.gdk.INTERP_NEAREST
|
gtk.gdk.INTERP_NEAREST
|
||||||
))
|
))
|
||||||
pb = image2.get_pixbuf()
|
pb = basepatch.get_pixbuf()
|
||||||
|
|
||||||
for (x,y) in [(0,0), (51,0), (104,0)]:
|
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(
|
pb.composite(
|
||||||
image.get_pixbuf(),
|
image.get_pixbuf(),
|
||||||
x * scale, y * scale,
|
x * scale, y * scale,
|
||||||
|
@ -64,12 +62,11 @@ class ImagesExample:
|
||||||
gtk.gdk.INTERP_NEAREST, 255
|
gtk.gdk.INTERP_NEAREST, 255
|
||||||
)
|
)
|
||||||
|
|
||||||
# a button to contain the image widget
|
# a button to contain the image widget
|
||||||
button = gtk.Button()
|
button = gtk.Button()
|
||||||
button.add(image)
|
button.add(image)
|
||||||
button.show()
|
button.show()
|
||||||
hbox.pack_start(button)
|
hbox.pack_start(button)
|
||||||
button.connect("clicked", self.button_clicked, "2")
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
gtk.main()
|
gtk.main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue