Skip to content

SvgRenderer

Base classes

Name Children Inherits
ObjectMixin
prettyqt.core.object
QSvgRenderer
PySide6.QtSvg
QSvgRenderer(self, contents: PySide6.QtCore.QXmlStreamReader, /, parent: PySide6.QtCore.QObject | None \= None, *, viewBox: PySide6.QtCore.QRectF | None \= None, framesPerSecond: int | None \= None, currentFrame: int | None \= None, aspectRatioMode: PySide6.QtCore.Qt.AspectRatioMode | None \= None, options: PySide6.QtSvg.QtSvg.Option | None \= None, animationEnabled: bool | None \= None) -> None

⋔ Inheritance diagram

graph TD
  4282116441["svg.SvgRenderer"]
  3227531497["core.ObjectMixin"]
  2751680898["builtins.object"]
  1531175686["QtSvg.QSvgRenderer"]
  3984060476["QtCore.QObject"]
  37984305["Shiboken.Object"]
  3227531497 --> 4282116441
  2751680898 --> 3227531497
  1531175686 --> 4282116441
  3984060476 --> 1531175686
  37984305 --> 3984060476
  2751680898 --> 37984305

🛈 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:
            msg = "invalid path"
            raise ValueError(msg)

    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))

:fa-brands-github: Show source on GitHub