Skip to main content

QFitsWidget

A Qt widget for displaying FITS images, written in Python. It works with PySide6 or PyQt via qtpy.

Features

  • QFitsWidget shows an astropy PrimaryHDU, with cuts, stretch and colormap controls.
  • When the header has a WCS, the sky position under the mouse is available, for example in the context menu.
  • Optional overlays: center mark, compass directions, text overlay and a zoom view. Each one can be switched on and off and has its own color.
  • A customizable context menu. Header entries are Jinja templates, so you can show e.g. the RA/Dec of the clicked position.
  • QImageWidget shows raw image data (not FITS) with the same stretch controls, and StretchControls can be used on its own.

Installation

pip install qfitswidget

You also need a Qt binding, for example pip install pyside6.

Usage

import sys

from astropy.io import fits
from qtpy import QtWidgets

from qfitswidget import QFitsWidget, MenuHeader, MenuAction


def offset_telescope(pixel, wcs):
    print(f"Clicked pixel {pixel}, sky position {wcs}")


app = QtWidgets.QApplication(sys.argv)

viewer = QFitsWidget()
viewer.set_menu(
    [
        MenuHeader("RA: {{wcs.ra|hms}}, Dec: {{wcs.dec|dms}}"),
        MenuAction("Offset telescope to position", offset_telescope),
    ]
)
viewer.display(fits.open(sys.argv[1])[0])
viewer.resize(800, 600)
viewer.show()

sys.exit(app.exec())

test.py in this repository is a slightly longer version of this example.

Development

uv sync
uv run pytest

See CONTRIBUTING.md for the full workflow.

License

MIT, see LICENSE.

3rd party

Metadata

Release files for qfitswidget 1.2.2

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

Source distribution (sdist)

Source distribution for qfitswidget 1.2.2
File Size Uploaded
qfitswidget-1.2.2.tar.gz 25.2 kB Details

Built distribution (wheel)

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

Total release size: 56.4 kB

Release files / qfitswidget-1.2.2.tar.gz

Download URL qfitswidget-1.2.2.tar.gz
Size 25.2 kB
Tags Source
SHA-256 checksum
How to use checksums
71d47302796034b858d4bf7387cf2d8b9d2613d1ab984f0186c3855e8af6c9b6
BLAKE2b-256 checksum
How to use checksums
86651cdb4dcab2dcb6acfe062ab70a1b697a1a7a5b05fd2db1a43b89ad8c3933
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / qfitswidget-1.2.2-py3-none-any.whl

Download URL qfitswidget-1.2.2-py3-none-any.whl
Size 31.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ebbecee21671d1e5c9ae43c49d08c325ce6087f12b90a253448dc7b9174edace
BLAKE2b-256 checksum
How to use checksums
21d355ac4ffdf46ea3e2cc65f759c2c5cc606f12cdbff714b3dab9716e53ca52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
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