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 quickly building user interfaces.

⚙️ Features

Three modes:

  • Web mode: Generate web (stateless) applications.
  • Web View mode: Generate web view applications that can be packaged as native apps (no need to start a web server).
  • Zero mode: Generate pure HTML files that run directly in browsers without any dependencies.

📦 Installation

Zero mode:

pip install instaui -U

web mode

pip install instaui[web] -U

Web View mode

pip install instaui[webview] -U

🖥️ Quick Start

Below is a simple example of number summation. The result color changes dynamically based on the sum:

from instaui import ui, arco
arco.use()

@ui.page('/')
def home():
    num1 = ui.state(0)
    num2 = ui.state(0)

    # Automatically recalculates result when num1 or num2 changes 
    @ui.computed(inputs=[num1, num2])
    def result(num1: int, num2: int):
        return num1 + num2

    # Automatically updates text_color when result changes
    @ui.computed(inputs=[result])
    def text_color(result: int):
        return "red" if result % 2 == 0 else "blue"

    # UI components  
    arco.input_number(num1)
    ui.label("+")
    arco.input_number(num2)
    ui.label("=")
    ui.label(result).style({"color": text_color})

# when you deploy your web application, you need to set debug=False.
ui.server(debug=True).run()

Replace ui.server().run() with ui.webview().run() to switch to Web View mode:

...

# ui.server(debug=True).run()
ui.webview().run()

To execute computations on the client side instead of the server, use ui.js_computed instead of ui.computed:

from instaui import ui, arco
arco.use()

@ui.page('/')
def home():
    num1 = ui.state(0)
    num2 = ui.state(0)

    result = ui.js_computed(inputs=[num1, num2], code="(num1, num2) => num1 + num2")
    text_color = ui.js_computed(inputs=[result], code="(result) => result % 2 === 0? 'red' : 'blue'")

    # UI components
    ...

...

In this case, all interactions will run on the client side. Use Zero mode to generate a standalone HTML file:

from instaui import ui, arco,zero
arco.use()

@ui.page('/')
def home():
    num1 = ui.state(0)
    num2 = ui.state(0)

    result = ui.js_computed(inputs=[num1, num2], code="(num1, num2) => num1 + num2")
    text_color = ui.js_computed(inputs=[result], code="(result) => result % 2 === 0? 'red' : 'blue'")

    # UI components
    arco.input_number(num1)
    ui.label("+")
    arco.input_number(num2)
    ui.label("=")
    ui.label(result).style({"color": text_color})

with zero() as z:
    home()
    z.to_html('index.html')

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.3.2.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.3.2-py2.py3-none-any.whl (1.4 MB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: instaui-0.3.2.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.6

File hashes

Hashes for instaui-0.3.2.tar.gz
Algorithm Hash digest
SHA256 ff8bdccc34585497c09a218d6316eeba278a4a1b28b9f01a07b2be5041f2c717
MD5 7bc02fc45b49f0a4099788b1e96789b5
BLAKE2b-256 d288592005be7a0ca0314f02a4f7a46a72f041c9ac8802fb8825917d35d11d94

See more details on using hashes here.

File details

Details for the file instaui-0.3.2-py2.py3-none-any.whl.

File metadata

  • Download URL: instaui-0.3.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.6

File hashes

Hashes for instaui-0.3.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 db7cd16e6f5f039c682946a8ed759c1f9f8597ddb41874cfecfb2fbd9d62eafd
MD5 24196defb2a1c2cf3fe6930924cc08fe
BLAKE2b-256 d4620c39b982b88050b162bf1bbb56249a5690549f49d3c56a236b6febec61f8

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