Skip to main content

insta-ui is a Python-based UI library for rapidly building user interfaces.

Project description

insta-ui

English| 简体中文

📖 Introduction

insta-ui is a Python-based UI library for rapidly building user interfaces.

⚙️ Features

Three modes are provided:

  • Zero mode: Generates pure HTML files, requiring no dependencies. Simply open in a browser to run.
  • Web mode: Generates web applications.
  • Web view mode: Generates web view applications that can be packaged into local applications (without needing to start a web server).

📦 Installation

For zero mode:

pip install instaui -U

For web mode:

pip install instaui[web] -U

For web view mode:

pip install instaui[webview] -U

🖥️ Quick Start

Here's a Counter example where clicking the button will display the current count value on the button text.

zore mode:

from instaui import ui, html, zero

with zero():
    count = ui.ref(0)
    text = ui.str_format("Count: {}", count)

    html.button(text).on_click(
        "()=> count.value++", bindings={"count": count}
    )

    ui.to_html("./test.html")

Running the above code will generate a test.html file, which you can open in a browser to see the effect.

Web mode:

from instaui import ui, html

@ui.page("/")
def counter():
    count = ui.ref(0)
    text = ui.str_format("Count: {}", count)

    html.button(text).on_click("()=> count.value++", bindings={"count": count})


ui.server().run()

In web mode, we can define interaction functions for complex computations.

from instaui import ui, html

@ui.page("/")
def counter():
    count = ui.ref(0)
    # text = ui.str_format("Count: {}", count)

    @ui.computed(inputs=[count])
    def text(count: int):
        # Any Python operation
        return f"Current Count: {count}"


    html.button(text).on_click("()=> count.value++", bindings={"count": count})


ui.server().run()
  • The computation of text will generate network requests.
  • Button clicks, due to using JS binding, do not require network requests.

You can choose to handle any computation with either Python or JavaScript. Below is an example of handling the button click event using Python.

@ui.page("/")
def counter():
    count = ui.ref(0)

    @ui.computed(inputs=[count])
    def text(count: int):
        return f"Current Count: {count}"

    @ui.event(inputs=[count], outputs=[count])
    def add_count(count: int):
        return count + 1

    html.button(text).on_click(add_count)

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

instaui-0.1.8.tar.gz (1.6 MB view details)

Uploaded Source

Built Distribution

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

instaui-0.1.8-py3-none-any.whl (1.8 MB view details)

Uploaded Python 3

File details

Details for the file instaui-0.1.8.tar.gz.

File metadata

  • Download URL: instaui-0.1.8.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.11.2 Windows/10

File hashes

Hashes for instaui-0.1.8.tar.gz
Algorithm Hash digest
SHA256 c1b2b1165ba605612e211cadf22431929c324cd6b0d1d4e7168469e2fb27a83e
MD5 f78625c6be2f0a19b4c63c4f3c0d1b27
BLAKE2b-256 fe373fadd3975359b4158bc2d477a5a6b7f5294297fdfab9ad30d02f4144fa2e

See more details on using hashes here.

File details

Details for the file instaui-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: instaui-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.11.2 Windows/10

File hashes

Hashes for instaui-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 7c7c1210c9c3fab8deaae4712b8eafbfb58a3c200ea0094865fefc0781e7dce0
MD5 b8dafc02e46b2f0bd52a8033a3779242
BLAKE2b-256 770523572502a0287ad7cf83a437ec15432f08e85b6f2aaf74119fba6c6cd3da

See more details on using hashes here.

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