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.5.tar.gz (1.3 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.5-py3-none-any.whl (1.4 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: instaui-0.1.5.tar.gz
  • Upload date:
  • Size: 1.3 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.5.tar.gz
Algorithm Hash digest
SHA256 8727d06ca4243b49d35169abe0f619a6a6dd318cf5ac5c87129a16849e1c75ef
MD5 038f02a07dc2adcb2c6561709ad941e0
BLAKE2b-256 d283bea0d82d310ea8f0fe53cf60719944f9a3e60145ae32f024c0e9dd98a21d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: instaui-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 1.4 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 2090a424ff03a86acb0fbd628c0ca623fd9cc2e592d5b87d420d69b6308689e1
MD5 8352d106418b7c579d8400426e9f9335
BLAKE2b-256 37018ec7dff249f20ed60c8e13a8cc469aa0e4ae6fd15e054c0e68f6dc6f7119

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