Python GTK+ 3
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)
If you have any questions or comments on this post, please send them by email to vimal (at) disroot (dot) org.
If you would like your comment to remain anonymous, please state that in your email. In any case, your email address will not be published.