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.3.tar.gz (789.6 kB 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.3-py3-none-any.whl (847.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: instaui-0.1.3.tar.gz
  • Upload date:
  • Size: 789.6 kB
  • 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.3.tar.gz
Algorithm Hash digest
SHA256 30d62bccbdbfe5903560580f58f3bc0f62c2c016fe0b2fef4f3a4815d5056523
MD5 d00b979a7b1eaf019910e4e9667df3ad
BLAKE2b-256 9d15cffe2e5ab72087332e61b9de3de4c4818a0006e3aaa28b32a503ae7744e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: instaui-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 847.7 kB
  • 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 79aafa962fbdbfa0622cfb4f14ccde234a8c49d9ceb1e203f9606c3c1eab39ef
MD5 decc113f7501a174b5b11dfc07b379ed
BLAKE2b-256 a70333768dacef33213f67076311af1a99bff5cdfbd99fe5b73d0f421f6b800f

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