Skip to main content

Pywui is a Python package wrapper for pywebview to make easy the communication between python and JS and async support.

Project description

Version Python License

Description

Pywui is a Python package wrapper for pywebview to make easy the communication between python and JS and async support.

Getting started

    pip install pywui

Exampple

import asyncio
from datetime import datetime

from pywui import command, PyWuiApp, PyWuiWindow, listener


@listener("message", inject_window=True)
async def on_message(window: PyWuiWindow, message: str):
    print("Message received: {}".format(message))


@command(inject_window=True)
async def greet(window: PyWuiWindow):
    # window.toggle_fullscreen()
    window.emit("message", "Hello from python")
    print("Hello :::", window)
    return "Hello World!"


async def on_start(window: PyWuiWindow):
    async def send_time():
        while True:
            window.emit("time", datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
            await asyncio.sleep(1)

    await asyncio.create_task(send_time())


app = PyWuiApp(
    "Main Window",
    'http://localhost:5174',
    confirm_close=False
)
main_window = app.get_main_window()
app.run(func=on_start, args=[main_window], debug=True)

Stay in touch

License

PyWui is MIT licensed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywui-0.1.2.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

pywui-0.1.2-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file pywui-0.1.2.tar.gz.

File metadata

  • Download URL: pywui-0.1.2.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/23.4.0

File hashes

Hashes for pywui-0.1.2.tar.gz
Algorithm Hash digest
SHA256 bdbcde2aa9bbc2c920db6e614287f9652237dd3a3f0439a163aa9e016eb57d1b
MD5 2bc94370da438194f2bca989089a3eda
BLAKE2b-256 276e22c7c3a8c32462aae2320c2a1d7e660ccd49bdde137d5ccacafa1e7d7b03

See more details on using hashes here.

File details

Details for the file pywui-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pywui-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/23.4.0

File hashes

Hashes for pywui-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e00958e8af958559c07c452c357e791be28c5c107609c804ccdaefe5642c28fd
MD5 2e78ea479a363aba22401c32e1fe87cc
BLAKE2b-256 4042415016bdd62282d76d5098997cf84a5997d614e6e59c102ca7957d37dbea

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page