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: generates a stateless web application.
  • Web View mode: generates a web view application, which can be packaged as a local app (no need to start a web service).
  • Zero mode: generates a pure HTML file that can run directly in a browser without installing any dependencies.

📦 Installation

Zero mode:

pip install instaui -U
uv add instaui

web mode

pip install instaui[web] -U
uv add instaui[web]

Web View mode

pip install instaui[webview] -U
uv add instaui[webview]

🖥️ Quick Start

Install the TDesign UI library:

uv add instaui-tdesign[web]
# main.py
from instaui import ui
from instaui_tdesign import td

td.use(locale="en_US")

@ui.page('/')
def home():
    ui.text("Hello, world!")

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

📚 Getting Started

Below is a simple example of summing two numbers. The text color of the result changes dynamically based on whether the result is even or odd.

from instaui import ui
from instaui_tdesign import td

td.use(locale="en_US")

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

    # When num1 or num2 changes, result will be automatically recalculated
    @ui.computed
    def result(num1 = num1, num2 = num2):
        return num1 + num2

    # When result changes, text_color will be automatically updated
    @ui.computed
    def text_color(result = result):
        return "red" if result % 2 == 0 else "blue"

    # UI
    td.input_number(num1, theme="column")
    ui.text("+")
    td.input_number(num2, theme="column")
    ui.text("=")
    ui.text(result).style({"color": text_color})

# When deploying a web app, remove debug=True
ui.server(debug=True).run()

Replace ui.server().run() with ui.webview().run() to run in web view mode:

...

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

Methods bound with ui.computed are executed on the server side. If you want to run calculations on the client side, use ui.js_computed.

from instaui import ui
from instaui_tdesign import td

td.use(locale="en_US")

@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
    ...

...

In this case, all interactions are executed in the browser (client side). With zero mode, you can generate a pure HTML file that works without installing any dependencies:

from instaui import ui, zero
from instaui_tdesign import td

td.use(locale="en_US")

@ui.page('/')
def home():
    ...

zero().to_html(home, file='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.8.18.tar.gz (383.1 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.8.18-py3-none-any.whl (509.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: instaui-0.8.18.tar.gz
  • Upload date:
  • Size: 383.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for instaui-0.8.18.tar.gz
Algorithm Hash digest
SHA256 6179d1318f7316e523e71477548a2e19ececbebf8c787c106f079ca004caec91
MD5 a99265f945e9f3b5b895d8efb2114558
BLAKE2b-256 f7b0e5b1e27d484f2b3a188fc845bf24a1df248d2cfefaf8a0c5e41000d6fc73

See more details on using hashes here.

File details

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

File metadata

  • Download URL: instaui-0.8.18-py3-none-any.whl
  • Upload date:
  • Size: 509.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for instaui-0.8.18-py3-none-any.whl
Algorithm Hash digest
SHA256 b51759f676558c58631a2a4d8abdc49ee617c87791dde4535dd4dde91e7e576d
MD5 a09c7105e0b2ec5615903a4178624f6c
BLAKE2b-256 cf5758f3165df2130aa11d7ecb7e12999cad00d9706f52a2757f99acd4aa3064

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