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.6.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.6-py3-none-any.whl (1.8 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: instaui-0.1.6.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.6.tar.gz
Algorithm Hash digest
SHA256 dd0ca83da4e6e29414914b12004569a91be3003f411227df1e1b0bf49b240396
MD5 57c7bf3eee205a5daf899dd252cfaca5
BLAKE2b-256 c8e2c2eb267a959c00a5286a88977bf2ebc31fc461b8fb127a2451a511db4420

See more details on using hashes here.

File details

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

File metadata

  • Download URL: instaui-0.1.6-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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9bfe88bed0f6dafa0aa2548d39875e5826ab514f237616031c5e055ff17ea649
MD5 ae4b6071aecbe5645eb0902074392242
BLAKE2b-256 bbd275c2c456e420437ef53d5970d33ee81fe87773f1b72d1f74ecb5a9cb5dd2

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