pyface.i_image_resource module

The interface for an image resource.

class pyface.i_image_resource.IImageResource(adaptee, default=<class 'traits.adaptation.adaptation_error.AdaptationError'>)[source]

Bases: IImage

The interface for an image resource.

An image resource describes the location of an image and provides a way to create a toolkit-specific image on demand.

absolute_path = Str()

The absolute path to the image.

name = Str()

The name of the image.

search_path = List()

A list of directories, classes or instances that will be used to search for the image (see the resource manager for more details).

classmethod image_size(image)[source]

Get the size of a toolkit image

Parameters

image (toolkit image) – A toolkit image to compute the size of.

Returns

size – The (width, height) tuple giving the size of the image.

Return type

tuple

class pyface.i_image_resource.MImageResource(name, search_path=None)[source]

Bases: HasTraits

The mixin class that contains common code for toolkit specific implementations of the IImageResource interface.

Implements: __init__(), create_image()

create_image(size=None)[source]

Creates a toolkit-specific image for this resource.

Parameters

size ((int, int) or None) – The desired size as a width, height tuple, or None if wanting default image size.

Returns

image – The toolkit image corresponding to the resource and the specified size.

Return type

toolkit image