Skip to main content

qtreload

License PyPI Python version Tests

qtreload watches Python modules and stylesheets while your Qt application runs. Save a method, then try it again in the running application. You can also rebuild widgets when their construction code changes, inspect widgets, and reload QSS files.

The project grew out of missing the PyDev debugger's auto-reload feature after moving to PyCharm. It brings a similar development workflow to Python Qt applications, where restarting an application and navigating back to a widget can take time. Some changes still require recreating a widget or restarting the application; see limitations.

Installation

Install qtreload and a Qt binding. If your application already has a supported binding, install qtreload on its own.

pip install "qtreload[pyqt6]"
# Or use another supported binding, for example:
pip install "qtreload[pyside6]"

qtreload requires Python 3.11 or later and uses QtPy to work with PyQt or PySide.

Quick start

Run an existing application through qtreload, with the packages you want to watch:

qtreload --watch myapp,myplugin my_app.py --app-argument

Open the developer tools with Ctrl+Shift+F12 (Cmd+Shift+F12 on macOS). Edit a method in an imported module, save the file, and call the method again in the application. The tools show reload messages and let you change the watch list.

You can also run a module. If no modules are configured, qtreload watches its top-level package:

python -m qtreload -m myapp.main
qtreload --show --settings-key myapp -m myapp.main

The launcher installs the tools when the application starts its Qt event loop. Use --shortcut to change the shortcut. See the usage guide for applications that do not start an event loop.

Add developer tools to an application

Create the QApplication first, then install the tools. Configure the modules to watch in pyproject.toml or with QTRELOAD_HOT_RELOAD_MODULES.

import sys

from qtpy.QtWidgets import QApplication, QLabel
from qtreload import install_dev_tools

app = QApplication(sys.argv)
window = QLabel("Edit myapp while this window is open")
window.show()
tools = install_dev_tools(show=True)  # Keep a reference to the tools.
sys.exit(app.exec())
[tool.qtreload]
modules = ["myapp"]

For an opt-in widget embedded in your own interface, use install_hot_reload(). It returns None unless QTRELOAD_HOT_RELOAD=1 is set. See configuration for the available settings.

Reload a stylesheet

A HotReloader can watch a QSS file even when it is outside a watched package. Create the file before registering it.

from qtpy.QtWidgets import QApplication, QLabel
from qtreload import HotReloader

app = QApplication.instance() or QApplication([])
window = QLabel("Save styles/app.qss to update me")
window.show()
reloader = HotReloader(["myapp"], parent=app)
reloader.register_stylesheet("styles/app.qss")
app.exec()

Rebuild a widget

Changes to a widget's __init__ need a new instance. Register a factory to replace the existing widget when its module reloads:

from qtpy.QtWidgets import QApplication, QVBoxLayout, QWidget
from qtreload import HotReloader
from myapp.panels import SettingsPanel

app = QApplication.instance() or QApplication([])
window = QWidget()
layout = QVBoxLayout(window)
reloader = HotReloader(["myapp"], parent=app)
live = reloader.register_factory(lambda: SettingsPanel())
layout.addWidget(live.widget)
window.show()
app.exec()

Connect to live.evt_rebuilt to reconnect signals on the replacement. See usage for more examples and caveats.

Documentation

Read the documentation for configuration, the widget inspector, stylesheets, and reload limitations. The examples directory contains small applications you can run and edit.

To build the documentation locally from a checkout:

uv sync --no-dev --group docs
uv run --no-sync zensical serve
# Or build the site in site/:
uv run --no-sync zensical build --strict --clean

Acknowledgements

The module reloading engine is adapted from the PyDev debugger by Fabio Zadrozny.

Metadata

Release files for qtreload 0.3.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 qtreload 0.3.0
File Size Uploaded Provenance Actions
qtreload-0.3.0.tar.gz 73.4 kB Without provenance Details for qtreload-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for qtreload 0.3.0
File Interpreter ABI Platform Actions
qtreload-0.3.0-py3-none-any.whl Python 3 none any Details for qtreload-0.3.0-py3-none-any.whl

Total release size: 119.1 kB

Release files / qtreload-0.3.0.tar.gz

Download URL qtreload-0.3.0.tar.gz
Size 73.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5b2c4f58c51f9116036978111344bd1a4f28e32bc85c5f36a221128e3de6069e
BLAKE2b-256 checksum
How to use checksums
36aa0632ef6e9f21c98b1bc3022133524341db1411692a7d2e72c3dbefdb9cb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Release files / qtreload-0.3.0-py3-none-any.whl

Download URL qtreload-0.3.0-py3-none-any.whl
Size 45.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bed6d59176d9b44fba28e899c77c737f759a4a4391998a3f84b47b2dbbb06900
BLAKE2b-256 checksum
How to use checksums
996fb9596f94be675185553cf9e604fc523e9049327f07935cb60d645c1f9171
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Security for qtreload 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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