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.4.tar.gz (605.0 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.4-py3-none-any.whl (668.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: instaui-0.1.4.tar.gz
  • Upload date:
  • Size: 605.0 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.4.tar.gz
Algorithm Hash digest
SHA256 0d69404b1eebc3402d5cb5698b9d8afbc7ebd068d6ce779c91e44de381a62514
MD5 0dcd4302e3fb9489e611022633c39556
BLAKE2b-256 1eaebd9114333f5d03d8d674df230768a497950fb50b1b74cd5a9857c14e0c92

See more details on using hashes here.

File details

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

File metadata

  • Download URL: instaui-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 668.5 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2a78f9ae8c39260d9f1060dab28f4b8464aef1523de9fcf6b0dc179d75092c86
MD5 deabd27b80559af19c03627e112b891f
BLAKE2b-256 6d425a540e9a3e9871e368ec5c7e43ba17de674a37a2167d3e4b40da7733ca35

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