Skip to main content

Build Qt applications in a reactive, declarative, and composable way

Project description

qtcompose

Build Qt applications in a reactive, declarative, and composable way.

qtcompose lets you describe your UI as a tree of components whose properties are driven by reactive values. Update state and the UI updates automatically.

[!WARNING] This project is under active development. APIs and behavior may change quickly, and documentation is still in progress. Feedback and early experimentation are welcome.

Installation

pip install qtcompose

You’ll also need a Qt binding. The examples use PySide6.

pip install PySide6

Quick example

A small counter app where the label updates automatically when count changes:

from PySide6 import QtWidgets
from qtcompose.rx import Subject, fn
from qtcompose.ui import (
    QBoxLayoutItem,
    QLabel,
    QMainWindow,
    QPushButton,
    QVBoxLayout,
    QWidget,
)

app = QtWidgets.QApplication()

count = Subject(0)

window = QMainWindow(
    children=Subject(
        QWidget(
            layout=Subject(
                QVBoxLayout(
                    children=Subject(
                        [
                            QBoxLayoutItem.Child(
                                QLabel(
                                    text=fn.pipe(
                                        count,
                                        fn.map_(lambda cnt: f"Count: {cnt}")
                                    )
                                )
                            ),
                            QBoxLayoutItem.Child(
                                QPushButton(
                                    text=Subject("Click Me!"),
                                    on_click=Subject(
                                        lambda _: count.push(
                                            lambda prev: prev + 1
                                        )
                                    ),
                                )
                            ),
                        ]
                    )
                )
            )
        )
    )
)()

window.show()
app.exec()

Further reading

For a deeper explanation of the ideas behind this project, check out my blog post:

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

qtcompose-0.2.0.tar.gz (22.8 kB view details)

Uploaded Source

Built Distribution

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

qtcompose-0.2.0-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file qtcompose-0.2.0.tar.gz.

File metadata

  • Download URL: qtcompose-0.2.0.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for qtcompose-0.2.0.tar.gz
Algorithm Hash digest
SHA256 24320438c1e948d46902e9b7f9eadbfe78f4f3177fa497b3c8601c7ffc7780d7
MD5 e63c00ddaae6ec397feae47ce0341c83
BLAKE2b-256 440127d24155958cc6f334988df16057caf6394229824ed7190da1559acf4d30

See more details on using hashes here.

Provenance

The following attestation bundles were made for qtcompose-0.2.0.tar.gz:

Publisher: publish.yaml on Lucino772/qtcompose

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qtcompose-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: qtcompose-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for qtcompose-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 219beb259445009ea2e4f13d24c546c0fe9e09776a05a6ebe382e79f7379d1a4
MD5 f575051786055a1a0711e3e38b377f2e
BLAKE2b-256 0e55bedaee097a117b30c49e2f7bdff1ef115c1d8b938d34f4c7e7fc8048c4d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for qtcompose-0.2.0-py3-none-any.whl:

Publisher: publish.yaml on Lucino772/qtcompose

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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