Tutorial Scale image automatically to fit parent widget Reference allocation = parent_widget.get_allocation() desired_width = allocation.width desired_height = allocation.height pixbuf = gtk.gdk.pixbuf_new_from_file('your_image.png') pixbuf = pixbuf.scale_simple(desired_width, desired_height, gtk.gdk.INTERP_BILINEAR) image = gtk.image_new_from_pixbuf(pixbuf)
Scale image automatically to fit parent widget
allocation = parent_widget.get_allocation()
desired_width = allocation.width
desired_height = allocation.height
pixbuf = gtk.gdk.pixbuf_new_from_file('your_image.png')
pixbuf = pixbuf.scale_simple(desired_width, desired_height, gtk.gdk.INTERP_BILINEAR)
image = gtk.image_new_from_pixbuf(pixbuf)
Comments