instaui


Nameinstaui JSON
Version 0.4.0 PyPI version JSON
download
home_pageNone
Summaryinsta-ui is a Python-based UI library for rapidly building user interfaces.
upload_time2025-07-17 08:52:46
maintainerNone
docs_urlNone
authorNone
requires_python<3.14,>=3.8
licenseNone
keywords gui ui web
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # insta-ui

<div align="center">

English| [įŽ€äŊ“中文](./README.md)

</div>

## 📖 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:

```python
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:

```python
...

# 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`:

```python
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:

```python
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')

```
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "instaui",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.14,>=3.8",
    "maintainer_email": null,
    "keywords": "gui, ui, web",
    "author": null,
    "author_email": "CrystalWindSnake <568166495@qq.com>",
    "download_url": "https://files.pythonhosted.org/packages/91/49/d1627cc123b464fd3398d57dc3786555ac7bce8a4b63fffa82524431cd8a/instaui-0.4.0.tar.gz",
    "platform": null,
    "description": "# insta-ui\n\n<div align=\"center\">\n\nEnglish| [\u7b80\u4f53\u4e2d\u6587](./README.md)\n\n</div>\n\n## \ud83d\udcd6 Introduction\ninsta-ui is a Python-based UI library for quickly building user interfaces.\n\n## \u2699\ufe0f Features\nThree modes:\n\n- Web mode: Generate web (stateless) applications.\n- Web View mode: Generate web view applications that can be packaged as native apps (no need to start a web server).\n- Zero mode: Generate pure HTML files that run directly in browsers without any dependencies.\n\n \n## \ud83d\udce6 Installation\n\nZero mode:\n\n```\npip install instaui -U\n```\n\nweb mode\n\n```\npip install instaui[web] -U\n```\n\nWeb View mode\n```\npip install instaui[webview] -U\n```\n\n\n## \ud83d\udda5\ufe0f Quick Start\nBelow is a simple example of number summation. The result color changes dynamically based on the sum:\n\n```python\nfrom instaui import ui, arco\narco.use()\n\n@ui.page('/')\ndef home():\n    num1 = ui.state(0)\n    num2 = ui.state(0)\n\n    # Automatically recalculates result when num1 or num2 changes \n    @ui.computed(inputs=[num1, num2])\n    def result(num1: int, num2: int):\n        return num1 + num2\n\n    # Automatically updates text_color when result changes\n    @ui.computed(inputs=[result])\n    def text_color(result: int):\n        return \"red\" if result % 2 == 0 else \"blue\"\n\n    # UI components  \n    arco.input_number(num1)\n    ui.label(\"+\")\n    arco.input_number(num2)\n    ui.label(\"=\")\n    ui.label(result).style({\"color\": text_color})\n\n# when you deploy your web application, you need to set debug=False.\nui.server(debug=True).run()\n```\n\nReplace `ui.server().run()` with `ui.webview().run()` to switch to Web View mode:\n\n```python\n...\n\n# ui.server(debug=True).run()\nui.webview().run()\n```\n\nTo execute computations on the client side instead of the server, use `ui.js_computed` instead of `ui.computed`:\n\n```python\nfrom instaui import ui, arco\narco.use()\n\n@ui.page('/')\ndef home():\n    num1 = ui.state(0)\n    num2 = ui.state(0)\n\n    result = ui.js_computed(inputs=[num1, num2], code=\"(num1, num2) => num1 + num2\")\n    text_color = ui.js_computed(inputs=[result], code=\"(result) => result % 2 === 0? 'red' : 'blue'\")\n\n    # UI components\n    ...\n\n...\n\n```\n\nIn this case, all interactions will run on the client side. Use `Zero mode` to generate a standalone HTML file:\n\n```python\nfrom instaui import ui, arco,zero\narco.use()\n\n@ui.page('/')\ndef home():\n    num1 = ui.state(0)\n    num2 = ui.state(0)\n\n    result = ui.js_computed(inputs=[num1, num2], code=\"(num1, num2) => num1 + num2\")\n    text_color = ui.js_computed(inputs=[result], code=\"(result) => result % 2 === 0? 'red' : 'blue'\")\n\n    # UI components\n    arco.input_number(num1)\n    ui.label(\"+\")\n    arco.input_number(num2)\n    ui.label(\"=\")\n    ui.label(result).style({\"color\": text_color})\n\nwith zero() as z:\n    home()\n    z.to_html('index.html')\n\n```",
    "bugtrack_url": null,
    "license": null,
    "summary": "insta-ui is a Python-based UI library for rapidly building user interfaces.",
    "version": "0.4.0",
    "project_urls": null,
    "split_keywords": [
        "gui",
        " ui",
        " web"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1e8201d9d435418d2bf90d1c711e2d2abdc80fa8703bd63159bf9109ac1e1d11",
                "md5": "4280d60ab84c8ab5169c3df73ea02614",
                "sha256": "a3e89abb72b01391ecec78ef99e070887849ea23480ffd8a2bd02250506b3a36"
            },
            "downloads": -1,
            "filename": "instaui-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4280d60ab84c8ab5169c3df73ea02614",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.14,>=3.8",
            "size": 613259,
            "upload_time": "2025-07-17T08:52:44",
            "upload_time_iso_8601": "2025-07-17T08:52:44.269451Z",
            "url": "https://files.pythonhosted.org/packages/1e/82/01d9d435418d2bf90d1c711e2d2abdc80fa8703bd63159bf9109ac1e1d11/instaui-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "9149d1627cc123b464fd3398d57dc3786555ac7bce8a4b63fffa82524431cd8a",
                "md5": "8a54deae7566e9fa11c0b32e7825bc76",
                "sha256": "f97ea42d18f8c8417e5563644e3858d9caa7047d90531159c7aafa3da694359f"
            },
            "downloads": -1,
            "filename": "instaui-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "8a54deae7566e9fa11c0b32e7825bc76",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.14,>=3.8",
            "size": 543702,
            "upload_time": "2025-07-17T08:52:46",
            "upload_time_iso_8601": "2025-07-17T08:52:46.224716Z",
            "url": "https://files.pythonhosted.org/packages/91/49/d1627cc123b464fd3398d57dc3786555ac7bce8a4b63fffa82524431cd8a/instaui-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-17 08:52:46",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "instaui"
}
        
Elapsed time: 0.78686s