Skip to content

Movie

Base classes

Name Children Inherits
ObjectMixin
prettyqt.core.object
QMovie
PySide6.QtGui
QMovie(self, device: PySide6.QtCore.QIODevice, /, format: PySide6.QtCore.QByteArray | bytes | bytearray | memoryview \= Default(QByteArray), parent: PySide6.QtCore.QObject | None \= None, *, speed: int | None \= None, cacheMode: PySide6.QtGui.QMovie.CacheMode | None \= None) -> None

⋔ Inheritance diagram

graph TD
  992994514["gui.Movie"]
  3227531497["core.ObjectMixin"]
  2751680898["builtins.object"]
  887511447["QtGui.QMovie"]
  3984060476["QtCore.QObject"]
  37984305["Shiboken.Object"]
  3227531497 --> 992994514
  2751680898 --> 3227531497
  887511447 --> 992994514
  3984060476 --> 887511447
  37984305 --> 3984060476
  2751680898 --> 37984305

🛈 DocStrings

Bases: ObjectMixin, QMovie

Convenience class for playing movies with QImageReader.

Source code in prettyqt/gui/movie.py
class Movie(core.ObjectMixin, QtGui.QMovie):
    """Convenience class for playing movies with QImageReader."""

    def __repr__(self):
        return get_repr(self, self.fileName(), self.get_format())

    def _get_map(self):
        maps = super()._get_map()
        maps |= {"cacheMode": CACHE_MODE}
        return maps

    def set_cache_mode(self, mode: CacheModeStr | QtGui.QMovie.CacheMode):
        """Set cache mode.

        Args:
            mode: cache mode
        """
        self.setCacheMode(CACHE_MODE.get_enum_value(mode))

    def get_cache_mode(self) -> CacheModeStr:
        """Get the current cache mode.

        Returns:
            cache mode
        """
        return CACHE_MODE.inverse[self.cacheMode()]

    def get_state(self) -> MovieStateStr:
        """Get the current state.

        Returns:
            state
        """
        return MOVIE_STATE.inverse[self.state()]

    def get_format(self) -> str:
        return bytes(self.format().data()).decode()

    @classmethod
    def get_supported_formats(cls) -> list[str]:
        return [bytes(i.data()).decode() for i in cls.supportedFormats()]

get_cache_mode() -> CacheModeStr

Get the current cache mode.

Source code in prettyqt/gui/movie.py
def get_cache_mode(self) -> CacheModeStr:
    """Get the current cache mode.

    Returns:
        cache mode
    """
    return CACHE_MODE.inverse[self.cacheMode()]

get_state() -> MovieStateStr

Get the current state.

Source code in prettyqt/gui/movie.py
def get_state(self) -> MovieStateStr:
    """Get the current state.

    Returns:
        state
    """
    return MOVIE_STATE.inverse[self.state()]

set_cache_mode(mode: CacheModeStr | QtGui.QMovie.CacheMode)

Set cache mode.

Parameters:

Name Type Description Default
mode CacheModeStr | CacheMode

cache mode

required
Source code in prettyqt/gui/movie.py
def set_cache_mode(self, mode: CacheModeStr | QtGui.QMovie.CacheMode):
    """Set cache mode.

    Args:
        mode: cache mode
    """
    self.setCacheMode(CACHE_MODE.get_enum_value(mode))

:fa-brands-github: Show source on GitHub