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.5.tar.gz (249.5 kB view details)

Uploaded Source

Built Distribution

pywui-0.1.5-py3-none-any.whl (249.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pywui-0.1.5.tar.gz
  • Upload date:
  • Size: 249.5 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.5.tar.gz
Algorithm Hash digest
SHA256 ae28fb78b79fe19b1777a0d26e362d6cd32c5c2749981035341e3a01bacebdfd
MD5 f56a1de46b3df8ae0a58f8e6022de9eb
BLAKE2b-256 c615bc318c1122321ec2eb885eca74bfbc661deee6f7db67df423aa780beeccb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pywui-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 249.1 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a28098c66a717903a7957ea428983c8de4f10713848cc52054f0c282f09e3219
MD5 3d183ec5b5d30197968418265bb2138f
BLAKE2b-256 b723531367de0e7cb43263da525053ef18bd60187d917694a66c318a0a024b08

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