Skip to content

SvgRenderer

Qt Base Class: QSvgRenderer

Signature: QSvgRenderer(self, contents: PySide6.QtCore.QXmlStreamReader, parent: Optional[PySide6.QtCore.QObject] = None) -> None QSvgRenderer(self, contents: Union[PySide6.QtCore.QByteArray, bytes], parent: Optional[PySide6.QtCore.QObject] = None) -> None QSvgRenderer(self, filename: str, parent: Optional[PySide6.QtCore.QObject] = None) -> None QSvgRenderer(self, parent: Optional[PySide6.QtCore.QObject] = None) -> None

Base classes

Name Children Inherits
ObjectMixin
prettyqt.core.object
QSvgRenderer
PySide6.QtSvg
QSvgRenderer(self, contents: PySide6.QtCore.QXmlStreamReader, parent: Optional[PySide6.QtCore.QObject] \= None) -> None

⋔ Inheritance diagram

graph TD
  1473374544304["svg.SvgRenderer"]
  1473299815024["core.ObjectMixin"]
  140713234304496["builtins.object"]
  1473369403104["QtSvg.QSvgRenderer"]
  1473288842240["QtCore.QObject"]
  1473291690208["Shiboken.Object"]
  1473299815024 --> 1473374544304
  140713234304496 --> 1473299815024
  1473369403104 --> 1473374544304
  1473288842240 --> 1473369403104
  1473291690208 --> 1473288842240
  140713234304496 --> 1473291690208

🛈 DocStrings

Bases: ObjectMixin, QSvgRenderer

Source code in prettyqt\svg\svgrenderer.py
class SvgRenderer(core.ObjectMixin, QtSvg.QSvgRenderer):
    def load_file(self, path: datatypes.PathType):
        result = self.load(os.fspath(path))
        if not result:
            raise ValueError("invalid path")

    def set_aspect_ratio_mode(
        self, mode: constants.AspectRatioModeStr | constants.AspectRatioMode
    ):
        """Set the aspect ratio mode.

        Args:
            mode: aspect ratio mode
        """
        self.setAspectRatioMode(constants.ASPECT_RATIO_MODE.get_enum_value(mode))

    def get_aspect_ratio_mode(self) -> constants.AspectRatioModeStr:
        """Return current aspect ratio mode.

        Returns:
            aspect ratio mode
        """
        return constants.ASPECT_RATIO_MODE.inverse[self.aspectRatioMode()]

get_aspect_ratio_mode() -> constants.AspectRatioModeStr

Return current aspect ratio mode.

Source code in prettyqt\svg\svgrenderer.py
def get_aspect_ratio_mode(self) -> constants.AspectRatioModeStr:
    """Return current aspect ratio mode.

    Returns:
        aspect ratio mode
    """
    return constants.ASPECT_RATIO_MODE.inverse[self.aspectRatioMode()]

set_aspect_ratio_mode(mode: constants.AspectRatioModeStr | constants.AspectRatioMode)

Set the aspect ratio mode.

Parameters:

Name Type Description Default
mode AspectRatioModeStr | AspectRatioMode

aspect ratio mode

required
Source code in prettyqt\svg\svgrenderer.py
def set_aspect_ratio_mode(
    self, mode: constants.AspectRatioModeStr | constants.AspectRatioMode
):
    """Set the aspect ratio mode.

    Args:
        mode: aspect ratio mode
    """
    self.setAspectRatioMode(constants.ASPECT_RATIO_MODE.get_enum_value(mode))

⌗ Property table

Qt Property Type Doc
objectName QString
viewBox QRectF
framesPerSecond int
currentFrame int
aspectRatioMode Qt::AspectRatioMode