Skip to main content

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

Metadata

Release files for resource-getters 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for resource-getters 1.0.0
File Size Uploaded
resource_getters-1.0.0.tar.gz 2.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for resource-getters 1.0.0
File Interpreter ABI Platform
resource_getters-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.6 kB

Release files / resource_getters-1.0.0.tar.gz

Download URL resource_getters-1.0.0.tar.gz
Size 2.7 kB
Tags Source
SHA-256 checksum
How to use checksums
421e1714480668ed2a8a284156c9d3be82a6fae3d145151db069deeffd47983b
BLAKE2b-256 checksum
How to use checksums
d4a6b52721535476088f7ea9cbd2d9fdfb1fdd15f3720a22ebd1b8534bd9625e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.12

Release files / resource_getters-1.0.0-py3-none-any.whl

Download URL resource_getters-1.0.0-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2b22293acb8b165b1fc78e3456885c5e4b9c692e3d9827a8c39ab5681ccdb1a7
BLAKE2b-256 checksum
How to use checksums
131237de156af8f26c650824dc463a8760a0dde460ba15ccc49c5e407d5d9866
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.12

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page