Image#

macOS

GTK

Windows

iOS

Android

Web

y

y

y

y

y

An image is graphical content of arbitrary size.

A Toga icon is a late bound resource - that is, it can be constructed without an implementation. When it is assigned to an ImageView, or other role where an Image is required, it is bound to a factory, at which time the implementation is created.

The path specified for an Image can be:

  1. A path relative to the module that defines your Toga application.

  2. An absolute filesystem path

  3. A URL. The content of the URL will be loaded in the background.

If the path specified does not exist, or cannot be loaded, a FileNotFoundError will be raised.

Usage#

Reference#

class toga.images.Image(path=None, *, data=None)#

A representation of graphical content.

Parameters:
  • path – Path to the image. Allowed values can be local file (relative or absolute path) or URL (HTTP or HTTPS). Relative paths will be interpreted relative to the application module directory.

  • data – A bytes object with the contents of an image in a supported format.

bind(factory=None)#
save(path)#

Save image to given path.

Parameters:

path – Path where to save the image.