Edifice#

Edifice is a Python library declarative framework for application user interfaces.

  • Modern declarative UI paradigm from web development.

  • 100% Python application development, no language inter-op.

  • A native Qt desktop app instead of a bundled web browser.

  • Fast iteration via hot-reloading.

Edifice uses PySide6 or PyQt6 as a backend. Edifice is like React, but with Python instead of JavaScript, and Qt Widgets instead of the HTML DOM. If you have React experience, you’ll find Edifice easy to learn. Edifice has function Components, Props, and Hooks just like React.

Getting Started#

Installation from pypi.org/project/pyedifice#
pip install PySide6-Essentials
pip install pyedifice
Hello World in Edifice#
from edifice import App, Label, Window, component

@component
def HelloWorld(self):
    with Window():
        Label("Hello World!")

if __name__ == "__main__":
    App(HelloWorld()).start()

For more, see the Tutorial. To understand the core concepts behind Edifice, see Edifice Core.

Table of Contents#

Why Edifice?#

Declarative

Most existing GUI libraries in Python, such as Tkinter and Qt, operate imperatively. To create a dynamic application using these libraries, you must not only think about what widgets to display to the user, but also how to issue the commands to modify the widgets.

With Edifice the developer need only declare what is rendered, not how the content is rendered.

User interactions update the application state, the state renders to a widget tree, and Edifice modifies the existing widget tree to reflect the new state.

Edifice code looks like this:

number, set_number = use_state(0)

with VBoxView():
    Button("Add 5", on_click=lambda event: set_number(number+5))
    Label(str(number))
    if number > 30 and number < 70:
        Label("Number is mid")

The GUI displays a button and a label with the current value of number. Clicking the button will add 5 to the number. If the number is “mid” then another label will reveal that fact.

Developer Tools

  • Dynamic hot-reloading of source code changes.

  • Element Inspector.

See Developer Tools for more details.

Edifice vs. Qt Quick

Qt Quick is Qt’s declarative GUI framework for Qt.

Qt Quick programs are written in Python + the special QML language + JavaScript.

Edifice programs are written in Python.

Because Edifice programs are only Python, binding to the UI is much more straightforward. Edifice makes it easy to dynamically create, mutate, shuffle, and destroy sections of the UI. Qt Quick assumes a much more static interface.

Qt Quick is like DOM + HTML + JavaScript, whereas Edifice is like React. QML and HTML are both declarative UI languages but they require imperative logic in another language for dynamism. Edifice and React allow fully dynamic applications to be specified declaratively in one language.

Extendable

Edifice does not support every feature of Qt, but it is easy to interface with Qt, either incorporating a Qt Widget into an Edifice component, use Qt commands directly with an existing Edifice component, or incorporating Edifice components in a Qt application.

Poetry Build System#

The Poetry pyproject.toml specifies the package dependecies.

Because Edifice supports PySide6 and PyQt6 at the same time, neither are required by [tool.poetry.dependencies]. Instead they are both optional [tool.poetry.group.dev.dependencies]. A project which depends on Edifice should also depend on either PySide6-Essentials or PySide6 or PyQt6.

The requirements.txt is generated by

poetry export -f requirements.txt --output requirements.txt

License and Code Availability#

The source code is avaliable on github/pyedifice.

Edifice is released under the MIT License.

Edifice uses Qt under the hood, and both PyQt6 and PySide6 are supported. Note that PyQt6 is distributed with the GPL license while PySide6 is distributed under the more flexible LGPL license.

See PyQt vs PySide Licensing.

Can I use PySide for commercial applications?

Yes, and you don’t need to release your source code to customers. The LGPL only requires you to release any changes you make to PySide itself.

Support#

Submit bug reports or feature requests on Github Issues.

Submit questions on Github Discussions.

Indices and tables#