Skip to main content

A minimal utility package for accessing application resources (icons, images, translations) in a clean and reusable way.

Project description

resource-getters

A minimal utility package for accessing application resources (icons, images, translations) in a clean and reusable way.

🔧 Features

  • Safe, Pythonic access to resource files inside packages
  • Uses importlib.resources (Python 3.9+)
  • Extensible ResourceGetter class
  • Supports logical grouping (e.g. icons, images, translations)
  • Compatible with zipped packages, wheels, and editable installs
  • Designed to support PySide6/Qt apps, but fully framework-agnostic

📦 Installation

pip install resource-getters

🚀 Usage

1. Structure your local resources

Your application should have a structure like:

your_app/
└── resources/
    ├── __init__.py
    ├── icons/
    ├── images/
    └── translations/

Only __init__.py in resources/ is required to make it a proper package.

No code logic is needed in resources/ — just the files.

2. Initialize resource-getters in your app

# your_app/app.py
import resource_getters

import your_app.resources as app_resources


resource_getters.configure(resource_package=app_resources)

3. Use resource getters to access files

import importlib.resources

from PySide6.QtGui import QPixmap
from resourcetools import Image

with importlib.resources.as_file(Image("image.png")) as real_path:
            pixmap: QPixmap = QPixmap(str(real_path))

📚 API Reference

configure(resource_package: ModuleType)

Sets the base resource package to use for Icon, Image, and Translations.

Icon(filename: str) -> Traversable

Returns a Traversable object (e.g. file path) to an icon file.

Same for:

Image(filename: str)

Translations(filename: str)

✅ Why importlib.resources?

  • Built into the Python standard library
  • Zip-safe (works with packages in wheels or zipapps)
  • Avoids hardcoded filesystem paths

🧪 Compatibility

  • Python 3.9+
  • Works with importlib.resources standard API
  • No external dependencies

📜 License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

resource_getters-1.0.0.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

resource_getters-1.0.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file resource_getters-1.0.0.tar.gz.

File metadata

  • Download URL: resource_getters-1.0.0.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.12

File hashes

Hashes for resource_getters-1.0.0.tar.gz
Algorithm Hash digest
SHA256 421e1714480668ed2a8a284156c9d3be82a6fae3d145151db069deeffd47983b
MD5 2c9151995f9b2b0e2093c2fa5ecba28b
BLAKE2b-256 d4a6b52721535476088f7ea9cbd2d9fdfb1fdd15f3720a22ebd1b8534bd9625e

See more details on using hashes here.

File details

Details for the file resource_getters-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for resource_getters-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b22293acb8b165b1fc78e3456885c5e4b9c692e3d9827a8c39ab5681ccdb1a7
MD5 6da6b898a6f78a683015826ac8e4be13
BLAKE2b-256 131237de156af8f26c650824dc463a8760a0dde460ba15ccc49c5e407d5d9866

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page