• PySide 模块
  • PySide.QtGui
  • 内容表

    上一话题

    QTextDocument

    下一话题

    QImageWriter

    QMovie

    概要

    信号

    静态函数

    详细描述

    PySide.QtGui.QMovie class is a convenience class for playing movies with PySide.QtGui.QImageReader .

    This class is used to show simple animations without sound. If you want to display video and media content, use the Phonon multimedia framework instead.

    First, create a PySide.QtGui.QMovie object by passing either the name of a file or a pointer to a PySide.QtCore.QIODevice containing an animated image format to PySide.QtGui.QMovie ‘s constructor. You can call PySide.QtGui.QMovie.isValid() to check if the image data is valid, before starting the movie. To start the movie, call PySide.QtGui.QMovie.start() . PySide.QtGui.QMovie 将进入 运行 state, and emit PySide.QtGui.QMovie.started() and PySide.QtGui.QMovie.stateChanged() . To get the current state of the movie, call PySide.QtGui.QMovie.state() .

    To display the movie in your application, you can pass your PySide.QtGui.QMovie 对象到 QLabel.setMovie() 。范例:

    label = QLabel()
    movie = QMovie("animations/fire.gif")
    label.setMovie(movie)
    movie.start()
    										

    Whenever a new frame is available in the movie, PySide.QtGui.QMovie 将发射 PySide.QtGui.QMovie.updated() . If the size of the frame changes, PySide.QtGui.QMovie.resized() is emitted. You can call PySide.QtGui.QMovie.currentImage() or PySide.QtGui.QMovie.currentPixmap() to get a copy of the current frame. When the movie is done, PySide.QtGui.QMovie 发射 PySide.QtGui.QMovie.finished() . If any error occurs during playback (i.e, the image file is corrupt), PySide.QtGui.QMovie 将发射 PySide.QtGui.QMovie.error() .

    You can control the speed of the movie playback by calling PySide.QtGui.QMovie.setSpeed() , which takes the percentage of the original speed as an argument. Pause the movie by calling setPaused(true). PySide.QtGui.QMovie will then enter Paused state and emit PySide.QtGui.QMovie.stateChanged() . If you call setPaused(false), PySide.QtGui.QMovie will reenter 运行 state and start the movie again. To stop the movie, call PySide.QtGui.QMovie.stop() .

    Certain animation formats allow you to set the background color. You can call PySide.QtGui.QMovie.setBackgroundColor() to set the color, or PySide.QtGui.QMovie.backgroundColor() to retrieve the current background color.

    PySide.QtGui.QMovie.currentFrameNumber() returns the sequence number of the current frame. The first frame in the animation has the sequence number 0. PySide.QtGui.QMovie.frameCount() returns the total number of frames in the animation, if the image format supports this. You can call PySide.QtGui.QMovie.loopCount() to get the number of times the movie should loop before finishing. PySide.QtGui.QMovie.nextFrameDelay() returns the number of milliseconds the current frame should be displayed.

    PySide.QtGui.QMovie can be instructed to cache frames of an animation by calling PySide.QtGui.QMovie.setCacheMode() .

    调用 PySide.QtGui.QMovie.supportedFormats() for a list of formats that PySide.QtGui.QMovie 支持。

    class PySide.QtGui. QMovie ( device [ , format=QByteArray() [ , parent=None ] ] )
    class PySide.QtGui. QMovie ( [ parent=None ] )
    class PySide.QtGui. QMovie ( fileName [ , format=QByteArray() [ , parent=None ] ] )
    参数:

    构造 PySide.QtGui.QMovie 对象。 PySide.QtGui.QMovie will use read image data from device , which it assumes is open and readable. If format is not empty, PySide.QtGui.QMovie will use the image format format for decoding the image data. Otherwise, PySide.QtGui.QMovie will attempt to guess the format.

    parent 对象被传递给 PySide.QtCore.QObject ‘s constructor.

    构造 PySide.QtGui.QMovie object, passing the parent 对象到 PySide.QtCore.QObject ‘s constructor.

    构造 PySide.QtGui.QMovie 对象。 PySide.QtGui.QMovie will use read image data from fileName 。若 format is not empty, PySide.QtGui.QMovie will use the image format format for decoding the image data. Otherwise, PySide.QtGui.QMovie will attempt to guess the format.

    parent 对象被传递给 PySide.QtCore.QObject ‘s constructor.

    PySide.QtGui.QMovie. CacheMode

    此枚举描述不同缓存模式,为 PySide.QtGui.QMovie .

    常量 描述
    QMovie.CacheNone 没有帧被缓存 (默认)。
    QMovie.CacheAll 所有帧都被缓存。
    PySide.QtGui.QMovie. MovieState

    此枚举描述不同状态为 PySide.QtGui.QMovie .

    常量 描述
    QMovie.NotRunning The movie is not running. This is PySide.QtGui.QMovie ‘s initial state, and the state it enters after PySide.QtGui.QMovie.stop() has been called or the movie is finished.
    QMovie.Paused The movie is paused, and PySide.QtGui.QMovie stops emitting PySide.QtGui.QMovie.updated() or PySide.QtGui.QMovie.resized() . This state is entered after calling pause() or setPaused(true). The current frame number it kept, and the movie will continue with the next frame when unpause() or setPaused(false) is called.
    QMovie.Running The movie is running.
    PySide.QtGui.QMovie. backgroundColor ( )
    返回类型: PySide.QtGui.QColor

    Returns the background color of the movie. If no background color has been assigned, an invalid PySide.QtGui.QColor 被返回。

    PySide.QtGui.QMovie. cacheMode ( )
    返回类型: PySide.QtGui.QMovie.CacheMode

    This property holds the movie's cache mode.

    Caching frames can be useful when the underlying animation format handler that PySide.QtGui.QMovie relies on to decode the animation data does not support jumping to particular frames in the animation, or even “rewinding” the animation to the beginning (for looping). Furthermore, if the image data comes from a sequential device, it is not possible for the underlying animation handler to seek back to frames whose data has already been read (making looping altogether impossible).

    To aid in such situations, a PySide.QtGui.QMovie object can be instructed to cache the frames, at the added memory cost of keeping the frames in memory for the lifetime of the object.

    默认情况下,此特性被设为 CacheNone .

    另请参阅

    QMovie.CacheMode

    PySide.QtGui.QMovie. currentFrameNumber ( )
    返回类型: PySide.QtCore.int

    Returns the sequence number of the current frame. The number of the first frame in the movie is 0.

    PySide.QtGui.QMovie. currentImage ( )
    返回类型: PySide.QtGui.QImage

    返回当前帧,作为 PySide.QtGui.QImage .

    PySide.QtGui.QMovie. currentPixmap ( )
    返回类型: PySide.QtGui.QPixmap

    返回当前帧,作为 PySide.QtGui.QPixmap .

    PySide.QtGui.QMovie. device ( )
    返回类型: PySide.QtCore.QIODevice

    Returns the device PySide.QtGui.QMovie reads image data from. If no device has currently been assigned, 0 is returned.

    PySide.QtGui.QMovie. error ( error )
    参数: error PySide.QtGui.QImageReader.ImageReaderError
    PySide.QtGui.QMovie. fileName ( )
    返回类型: unicode

    Returns the name of the file that PySide.QtGui.QMovie reads image data from. If no file name has been assigned, or if the assigned device is not a file, an empty PySide.QtCore.QString 被返回。

    PySide.QtGui.QMovie. finished ( )
    PySide.QtGui.QMovie. format ( )
    返回类型: PySide.QtCore.QByteArray

    Returns the format that PySide.QtGui.QMovie uses when decoding image data. If no format has been assigned, an empty QByteArray() 被返回。

    PySide.QtGui.QMovie. frameChanged ( frameNumber )
    参数: frameNumber PySide.QtCore.int
    PySide.QtGui.QMovie. frameCount ( )
    返回类型: PySide.QtCore.int

    Returns the number of frames in the movie.

    Certain animation formats do not support this feature, in which case 0 is returned.

    PySide.QtGui.QMovie. frameRect ( )
    返回类型: PySide.QtCore.QRect

    Returns the rect of the last frame. If no frame has yet been updated, an invalid PySide.QtCore.QRect 被返回。

    PySide.QtGui.QMovie. isValid ( )
    返回类型: PySide.QtCore.bool

    Returns true if the movie is valid (e.g., the image data is readable and the image format is supported); otherwise returns false.

    PySide.QtGui.QMovie. jumpToFrame ( frameNumber )
    参数: frameNumber PySide.QtCore.int
    返回类型: PySide.QtCore.bool

    Jumps to frame number frameNumber . Returns true on success; otherwise returns false.

    PySide.QtGui.QMovie. jumpToNextFrame ( )
    返回类型: PySide.QtCore.bool

    Jumps to the next frame. Returns true on success; otherwise returns false.

    PySide.QtGui.QMovie. loopCount ( )
    返回类型: PySide.QtCore.int

    Returns the number of times the movie will loop before it finishes. If the movie will only play once (no looping), loopCount returns 0. If the movie loops forever, loopCount returns -1.

    Note that, if the image data comes from a sequential device (e.g. a socket), PySide.QtGui.QMovie can only loop the movie if the PySide.QtGui.QMovie.cacheMode() is set to QMovie.CacheAll .

    PySide.QtGui.QMovie. nextFrameDelay ( )
    返回类型: PySide.QtCore.int

    Returns the number of milliseconds PySide.QtGui.QMovie will wait before updating the next frame in the animation.

    PySide.QtGui.QMovie. resized ( size )
    参数: size PySide.QtCore.QSize
    PySide.QtGui.QMovie. scaledSize ( )
    返回类型: PySide.QtCore.QSize

    Returns the scaled size of frames.

    PySide.QtGui.QMovie. setBackgroundColor ( color )
    参数: color PySide.QtGui.QColor

    For image formats that support it, this function sets the background color to color .

    PySide.QtGui.QMovie. setCacheMode ( mode )
    参数: mode PySide.QtGui.QMovie.CacheMode

    This property holds the movie's cache mode.

    Caching frames can be useful when the underlying animation format handler that PySide.QtGui.QMovie relies on to decode the animation data does not support jumping to particular frames in the animation, or even “rewinding” the animation to the beginning (for looping). Furthermore, if the image data comes from a sequential device, it is not possible for the underlying animation handler to seek back to frames whose data has already been read (making looping altogether impossible).

    To aid in such situations, a PySide.QtGui.QMovie object can be instructed to cache the frames, at the added memory cost of keeping the frames in memory for the lifetime of the object.

    默认情况下,此特性被设为 CacheNone .

    另请参阅

    QMovie.CacheMode

    PySide.QtGui.QMovie. setDevice ( device )
    参数: device PySide.QtCore.QIODevice

    把当前设备设为 device . PySide.QtGui.QMovie will read image data from this device when the movie is running.

    PySide.QtGui.QMovie. setFileName ( fileName )
    参数: fileName – unicode

    Sets the name of the file that PySide.QtGui.QMovie reads image data from, to fileName .

    PySide.QtGui.QMovie. setFormat ( format )
    参数: format PySide.QtCore.QByteArray

    Sets the format that PySide.QtGui.QMovie will use when decoding image data, to format . By default, PySide.QtGui.QMovie will attempt to guess the format of the image data.

    可以调用 PySide.QtGui.QMovie.supportedFormats() for the full list of formats PySide.QtGui.QMovie 支持。

    PySide.QtGui.QMovie. setPaused ( paused )
    参数: paused PySide.QtCore.bool

    paused is true, PySide.QtGui.QMovie 将进入 Paused state and emit stateChanged(Paused); otherwise it will enter 运行 state and emit stateChanged(Running).

    另请参阅

    paused() PySide.QtGui.QMovie.state()

    PySide.QtGui.QMovie. setScaledSize ( size )
    参数: size PySide.QtCore.QSize

    Sets the scaled frame size to size .

    PySide.QtGui.QMovie. setSpeed ( percentSpeed )
    参数: percentSpeed PySide.QtCore.int

    This property holds the movie's speed.

    The speed is measured in percentage of the original movie speed. The default speed is 100%. Example:

    movie = QMovie("racecar.gif")
    movie.setSpeed(200) // 2x speed
    										
    PySide.QtGui.QMovie. speed ( )
    返回类型: PySide.QtCore.int

    This property holds the movie's speed.

    The speed is measured in percentage of the original movie speed. The default speed is 100%. Example:

    movie = QMovie("racecar.gif")
    movie.setSpeed(200) // 2x speed
    										
    PySide.QtGui.QMovie. start ( )

    Starts the movie. PySide.QtGui.QMovie 将进入 运行 state, and start emitting PySide.QtGui.QMovie.updated() and PySide.QtGui.QMovie.resized() as the movie progresses.

    PySide.QtGui.QMovie is in the Paused state, this function is equivalent to calling setPaused(false). If PySide.QtGui.QMovie is already in the 运行 state, this function does nothing.

    PySide.QtGui.QMovie. started ( )
    PySide.QtGui.QMovie. state ( )
    返回类型: PySide.QtGui.QMovie.MovieState

    返回当前状态,为 PySide.QtGui.QMovie .

    另请参阅

    QMovie.MovieState PySide.QtGui.QMovie.stateChanged()

    PySide.QtGui.QMovie. stateChanged ( state )
    参数: state PySide.QtGui.QMovie.MovieState
    PySide.QtGui.QMovie. stop ( )

    停止电影。 PySide.QtGui.QMovie 进入 NotRunning state, and stops emitting PySide.QtGui.QMovie.updated() and PySide.QtGui.QMovie.resized() 。若 PySide.QtGui.QMovie.start() is called again, the movie will restart from the beginning.

    PySide.QtGui.QMovie is already in the NotRunning state, this function does nothing.

    static PySide.QtGui.QMovie. supportedFormats ( )
    返回类型:

    Returns the list of image formats supported by PySide.QtGui.QMovie .

    PySide.QtGui.QMovie. updated ( rect )
    参数: rect PySide.QtCore.QRect