Skip to content

Resource

Qt Base Class: QResource

Signature: QResource(self, file: str = '', locale: Union[PySide6.QtCore.QLocale, PySide6.QtCore.QLocale.Language] = Default(QLocale)) -> None

Base classes

Name Children Inherits
QResource
PySide6.QtCore
QResource(self, file: str \= '', locale: Union[PySide6.QtCore.QLocale, PySide6.QtCore.QLocale.Language] \= Default(QLocale)) -> None

⋔ Inheritance diagram

graph TD
  1473299860896["core.Resource"]
  1473243604640["QtCore.QResource"]
  1473291690208["Shiboken.Object"]
  140713234304496["builtins.object"]
  1473243604640 --> 1473299860896
  1473291690208 --> 1473243604640
  140713234304496 --> 1473291690208

🛈 DocStrings

Bases: QResource

Interface for reading directly from resources.

Source code in prettyqt\core\resource.py
class Resource(core.QResource):
    """Interface for reading directly from resources."""

    def __repr__(self):
        return get_repr(self, self.absoluteFilePath(), self.get_locale())

    def __reduce__(self):
        return type(self), (self.absoluteFilePath(), self.get_locale())

    def __bytes__(self):
        return bytes(self.uncompressedData())

    def __bool__(self):
        return self.isValid()

    def __iter__(self) -> Iterator[str]:
        return iter(self.children())

    def get_compression_algorithm(self) -> CompressionStr:
        return COMPRESSION.inverse[self.compressionAlgorithm()]

    def get_absolute_file_path(self) -> pathlib.Path:
        return pathlib.Path(self.absoluteFilePath())

    def get_locale(self) -> core.Locale:
        return core.Locale(self.locale())

    def get_last_modified(self) -> core.DateTime:
        return core.DateTime(self.lastModified())

    def set_file_name(self, path: datatypes.PathType):
        self.setFileName(os.fspath(path))

    def get_file_name(self) -> pathlib.Path:
        return pathlib.Path(self.fileName())

    @classmethod
    def register_resource(cls, path: datatypes.PathType, root: str = ""):
        cls.registerResource(os.fspath(path), root)