Skip to main content

"PUI" Python Declarative UI Framework

Project description

Install

pip install QPUIQ

Example

Code

from PUI import State
# from PUI.tkinter import *
from PUI.PySide6 import *
# from PUI.Qt5 import *
# from PUI.flet import *

data = State()
data.var = 50
class Example(Application):
    def content(self):
        with Window(title="blah", size=(640,480)):
            with VBox():
                with Canvas():
                    CanvasText(data.var, data.var/2, f"blah {data.var}")
                    CanvasLine(data.var, data.var, data.var*2, data.var*3)
                with HBox():
                    Button("-", self.on_minus)
                    Label(f"{data.var}")
                    Button("+", self.on_plus)

    def on_minus(self):
        data.var -= 1

    def on_plus(self):
        data.var += 1

root = Example()
root.run()

UI

Qt Canvas Example

DOM

Example {
  QtVBox {
    QtCanvas {
      QtCanvasText {

      },
      QtCanvasLine {

      }
    },
    QtHBox {
      QtButton {

      },
      QtLabel {

      },
      QtButton {

      }
    }
  }
}

More Example

See examples/*.py

Planned Backends

  • tkinter
  • PyQt5
  • PySide6
  • flet
  • urwid (Text Mode)

Generic Expression

Elements

  • HBox()
  • VBox()
  • Button(text, callback)
  • Label(text)
  • TextField(binding)
  • ProgressBar(progress 0-1)
  • Canvas
    • CanvasText
    • CanvasLine(x1, y1, x2, y2, color=0xFF0000, width=2)

Layout

  • .layout(width=320, height=240, weight=1)

Hot Reload

Add these lines to your view file and run with reloadium

import reloadium

# reloadium: after_reload
def after_reload(actions):
    PUIView.reload()

Progress

  • Use threading.locals() instead of inspect
  • State
    • Update Trigger
    • Binding
    • StateList
    • StateDict
    • Lazy UI?
  • Passing state to subview
  • StateObject decorator
  • Adapters
    • Split Application/Window, multi-windows
    • Navigation Stack
    • View Router
    • Label
    • Button
    • TextField
    • TimelimeView
    • Layout
      • HBox
      • VBox
      • ZBox
      • Grid
        • Row
        • Column
      • SwiftUI style overlay ??
    • Canvas
      • Text
      • Line
      • Rect
      • Arc
      • Image
      • ...
    • Table
    • Tree
    • Scrollbar (or as a layout setting)
  • Better DOM syncer
    • Prevent unnecessary nested update
    • Trace Event Source (TextField) and prevent udpate it DOM Sync
    • update() -> sync()/inflate()/update() ?
  • Pydantic State

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

QPUIQ-0.1.12.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

QPUIQ-0.1.12-py3-none-any.whl (32.3 kB view details)

Uploaded Python 3

File details

Details for the file QPUIQ-0.1.12.tar.gz.

File metadata

  • Download URL: QPUIQ-0.1.12.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for QPUIQ-0.1.12.tar.gz
Algorithm Hash digest
SHA256 1d18fe8816c5e81effc0adec4740990f56db6e6d83c5cfa08089a7de885bf3a1
MD5 09c4be90ced6893f567ddd667c0fa831
BLAKE2b-256 98fefcc4e762d9087ef2e25208df873d5b2d12ae1a75b8aba4c62dc9ad79b011

See more details on using hashes here.

File details

Details for the file QPUIQ-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: QPUIQ-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 32.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for QPUIQ-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 3188b1074596739c3cb7da4a49f45d029a8a6bf868253f31cfba7394b6180fc5
MD5 5899015b24b13eb00582d5f48b500a96
BLAKE2b-256 5d52e86d18ab80f17a2228bbf55e4a81ac1760afbbf5e1e15a36f35c8819d0e4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page