Module QFlow.helpers

Sub-modules

QFlow.helpers.icon

This module defines the Icon class, which extends QPixmap to handle image loading and scaling …

QFlow.helpers.instanceArgs
QFlow.helpers.sessionStorage

Classes

class Icon (path: str, w: int, h: int)
Expand source code
class Icon(QPixmap):
    """
    Planned for package use only.
    
    A QPixmap subclass that loads and scales an image if the file exists.

    This class checks whether the specified image file exists before loading it.
    If the file is found, it scales the image while maintaining its aspect ratio.
    Otherwise, it initializes an empty QPixmap.
    """

    def __init__(self, path: str, w: int, h: int):
        """
        Initializes an Icon object.

        Args:
            path (str): The file path of the image.
            w (int): The desired width of the icon.
            h (int): The desired height of the icon.
        """
        if os.path.exists(path):
            pixmap = QPixmap(path).scaled(w, h, Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation)
            super().__init__(pixmap)
        else:
            super().__init__()

Planned for package use only.

A QPixmap subclass that loads and scales an image if the file exists.

This class checks whether the specified image file exists before loading it. If the file is found, it scales the image while maintaining its aspect ratio. Otherwise, it initializes an empty QPixmap.

Initializes an Icon object.

Args

path : str
The file path of the image.
w : int
The desired width of the icon.
h : int
The desired height of the icon.

Ancestors

  • PyQt6.QtGui.QPixmap
  • PyQt6.QtGui.QPaintDevice
  • PyQt6.sip.simplewrapper