GdkPixbuf.PixbufAnimation¶
- Subclasses:
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
|---|---|---|---|
parent_instance |
r |
Class Details¶
- class GdkPixbuf.PixbufAnimation(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
An opaque object representing an animation.
The GdkPixBuf library provides a simple mechanism to load and represent animations. An animation is conceptually a series of frames to be displayed over time.
The animation may not be represented as a series of frames internally; for example, it may be stored as a sprite and instructions for moving the sprite around a background.
To display an animation you don’t need to understand its representation, however; you just ask
GdkPixbufwhat should be displayed at a given point in time.- classmethod new_from_file(filename)[source]¶
- Parameters:
filename (
str) – Name of file to load, in the GLib file name encoding- Raises:
- Returns:
A newly-created animation
- Return type:
Creates a new animation by loading it from a file.
The file format is detected automatically.
If the file’s format does not support multi-frame images, then an animation with a single frame will be created.
Possible errors are in the
GDK_PIXBUF_ERRORandG_FILE_ERRORdomains.
- classmethod new_from_resource(resource_path)[source]¶
- Parameters:
resource_path (
str) – the path of the resource file- Raises:
- Returns:
A newly-created animation
- Return type:
Creates a new pixbuf animation by loading an image from an resource.
The file format is detected automatically. If
NULLis returned, then error will be set.New in version 2.28.
- classmethod new_from_stream(stream, cancellable)[source]¶
- Parameters:
stream (
Gio.InputStream) – aGInputStreamto load the pixbuf fromcancellable (
Gio.CancellableorNone) – optionalGCancellableobject
- Raises:
- Returns:
A newly-created animation
- Return type:
Creates a new animation by loading it from an input stream.
The file format is detected automatically.
If
NULLis returned, then error will be set.The cancellable can be used to abort the operation from another thread. If the operation was cancelled, the error
G_IO_ERROR_CANCELLEDwill be returned. Other possible errors are in theGDK_PIXBUF_ERRORandG_IO_ERRORdomains.The stream is not closed.
New in version 2.28.
- classmethod new_from_stream_async(stream, cancellable, callback, *user_data)[source]¶
- Parameters:
stream (
Gio.InputStream) – aGio.InputStreamfrom which to load the animationcancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobjectcallback (
Gio.AsyncReadyCallbackorNone) – aGAsyncReadyCallbackto call when the pixbuf is loadeduser_data (
objectorNone) – the data to pass to the callback function
Creates a new animation by asynchronously loading an image from an input stream.
For more details see
GdkPixbuf.Pixbuf.new_from_stream(), which is the synchronous version of this function.When the operation is finished,
callbackwill be called in the main thread. You can then callGdkPixbuf.PixbufAnimation.new_from_stream_finish() to get the result of the operation.New in version 2.28.
- classmethod new_from_stream_finish(async_result)[source]¶
- Parameters:
async_result (
Gio.AsyncResult) – aGio.AsyncResult- Raises:
- Returns:
the newly created animation
- Return type:
Finishes an asynchronous pixbuf animation creation operation started with [func`GdkPixbuf`.PixbufAnimation.new_from_stream_async].
New in version 2.28.
- get_height()[source]¶
- Returns:
Height of the bounding box of the animation.
- Return type:
Queries the height of the bounding box of a pixbuf animation.
- get_iter(start_time)[source]¶
- Parameters:
start_time (
GLib.TimeValorNone) – time when the animation starts playing- Returns:
an iterator to move over the animation
- Return type:
Get an iterator for displaying an animation.
The iterator provides the frames that should be displayed at a given time.
start_time would normally come from
GLib.get_current_time(), and marks the beginning of animation playback. After creating an iterator, you should immediately display the pixbuf returned byGdkPixbuf.PixbufAnimationIter.get_pixbuf(). Then, you should install a timeout (withGLib.timeout_add()) or by some other mechanism ensure that you’ll update the image afterGdkPixbuf.PixbufAnimationIter.get_delay_time() milliseconds. Each time the image is updated, you should reinstall the timeout with the new, possibly-changed delay time.As a shortcut, if start_time is
NULL, the result ofGLib.get_current_time() will be used automatically.To update the image (i.e. possibly change the result of
GdkPixbuf.PixbufAnimationIter.get_pixbuf() to a new frame of the animation), callGdkPixbuf.PixbufAnimationIter.advance().If you’re using
GdkPixbuf.PixbufLoader, in addition to updating the image after the delay time, you should also update it whenever you receive the area_updated signal andGdkPixbuf.PixbufAnimationIter.on_currently_loading_frame() returnsTRUE. In this case, the frame currently being fed into the loader has received new data, so needs to be refreshed. The delay time for a frame may also be modified after an area_updated signal, for example if the delay time for a frame is encoded in the data after the frame itself. So your timeout should be reinstalled after any area_updated signal.A delay time of -1 is possible, indicating “infinite”.
- get_static_image()[source]¶
- Returns:
unanimated image representing the animation
- Return type:
Retrieves a static image for the animation.
If an animation is really just a plain image (has only one frame), this function returns that image.
If the animation is an animation, this function returns a reasonable image to use as a static unanimated image, which might be the first frame, or something more sophisticated depending on the file format.
If an animation hasn’t loaded any frames yet, this function will return
NULL.
- get_width()[source]¶
- Returns:
Width of the bounding box of the animation.
- Return type:
Queries the width of the bounding box of a pixbuf animation.
- is_static_image()[source]¶
- Returns:
TRUEif the “animation” was really just an image- Return type:
Checks whether the animation is a static image.
If you load a file with
GdkPixbuf.PixbufAnimation.new_from_file() and it turns out to be a plain, unanimated image, then this function will returnTRUE. UseGdkPixbuf.PixbufAnimation.get_static_image() to retrieve the image.
- do_get_iter(start_time) virtual¶
- Parameters:
start_time (
GLib.TimeValorNone) – time when the animation starts playing- Returns:
an iterator to move over the animation
- Return type:
Get an iterator for displaying an animation.
The iterator provides the frames that should be displayed at a given time.
start_time would normally come from
GLib.get_current_time(), and marks the beginning of animation playback. After creating an iterator, you should immediately display the pixbuf returned byGdkPixbuf.PixbufAnimationIter.get_pixbuf(). Then, you should install a timeout (withGLib.timeout_add()) or by some other mechanism ensure that you’ll update the image afterGdkPixbuf.PixbufAnimationIter.get_delay_time() milliseconds. Each time the image is updated, you should reinstall the timeout with the new, possibly-changed delay time.As a shortcut, if start_time is
NULL, the result ofGLib.get_current_time() will be used automatically.To update the image (i.e. possibly change the result of
GdkPixbuf.PixbufAnimationIter.get_pixbuf() to a new frame of the animation), callGdkPixbuf.PixbufAnimationIter.advance().If you’re using
GdkPixbuf.PixbufLoader, in addition to updating the image after the delay time, you should also update it whenever you receive the area_updated signal andGdkPixbuf.PixbufAnimationIter.on_currently_loading_frame() returnsTRUE. In this case, the frame currently being fed into the loader has received new data, so needs to be refreshed. The delay time for a frame may also be modified after an area_updated signal, for example if the delay time for a frame is encoded in the data after the frame itself. So your timeout should be reinstalled after any area_updated signal.A delay time of -1 is possible, indicating “infinite”.
- do_get_size(width, height) virtual¶
-
fills width and height with the frame size of the animation.
- do_get_static_image() virtual¶
- Returns:
unanimated image representing the animation
- Return type:
Retrieves a static image for the animation.
If an animation is really just a plain image (has only one frame), this function returns that image.
If the animation is an animation, this function returns a reasonable image to use as a static unanimated image, which might be the first frame, or something more sophisticated depending on the file format.
If an animation hasn’t loaded any frames yet, this function will return
NULL.
- do_is_static_image() virtual¶
- Returns:
TRUEif the “animation” was really just an image- Return type:
Checks whether the animation is a static image.
If you load a file with
GdkPixbuf.PixbufAnimation.new_from_file() and it turns out to be a plain, unanimated image, then this function will returnTRUE. UseGdkPixbuf.PixbufAnimation.get_static_image() to retrieve the image.