GtkPicture is meant to be used with images using their natural size; for fixed size images, like icons, you should use GtkImage instead.

// create an image
GtkWidget *image = gtk_picture_new ();

// set the content of the image using the gnome-image.png file
gtk_picture_set_from_file (GTK_PICTURE (image), "gnome-image.png");


If the image file is not loaded successfully, the image will contain a “broken image” icon. The gnome-image.png file needs to be in the current directory for this code to work.

Useful methods for a Picture widget

  • set_keep_aspect_ratio(True) will size the GtkPicture widget so that the aspect ratio of the image will be maintained when resizing the widget.

  • set_alternative_text("An image of a 1000 words") will set the string “An image of a 1000 words” as the textual representation of the image; this text will be used by accessibility tool.

API references