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()
class Example(Window):
    def __init__(self):
        super().__init__(title="blah", size=(640,480))
        data.var = 50

    def content(self):
        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

Layout

  • .layout(weight=1)
  • .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

  • 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.3.tar.gz (14.0 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: QPUIQ-0.1.3.tar.gz
  • Upload date:
  • Size: 14.0 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.3.tar.gz
Algorithm Hash digest
SHA256 01fbfd7f3a411c3a970b627134b93e5559bceef9dabd7be6b9be2242f93612b6
MD5 c77b55196f0e33dcb4754409eda40473
BLAKE2b-256 169c6b65c01d0da42562081d6a8ae0a56ebf3da5f6d5c54e13d06fbe627cd62f

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