Skip to main content

A simple module for making HTML GUI applications with python3/asyncio

Project description

wuy

If you have made a super python tool, and you want to add a GUI but without using qt/gtk/tk/wx/kivy/toga : you are in the right place ! Just re-use the local browser (chrome in app mode) as GUI, drived by wuy.


html / python

Basically, it's a python module which will act as a web server (http & websocket) and will open/manage a window for you ; providing a simple framework (js/py3 helpers).

It lets you create your GUI with yours web skills (html/js/css or any js frameworks/libs), and re-use the power of python on server side.

Technically, it's a python3 module, using asyncio and the marvellous aiohttp, and (if present) the uvloop, for the full speed ! The http server is here to serve static content (html, js, images ...). The websocket is here to simplify the communication (sync/async) between the window & the server. (rpc method to communicate from client to server, pubsub mechanism to communicate from server to clients, or from client to clients)

In app/window mode : it will manage (open/close) the window for you ; using the chrome app mode ; if the websocket brokes : window & server will shutdown (close the window ; the server will shutdown, close the server ; the window will shutdown). You (or your clients) will not see a difference with classical GUI !

In server mode : it will act as a classical web server ; and you can use as many clients/browsers as you want, from localhost or from anywhere else. Closing a socket ; just close the socket ;-). It can be hosted on the web, as long as the provider service use python3.

More on window/server differences

In all cases : it will be pretty easy to produce/freeze an executable/windows (one file with all html/js embedded), using pyinstaller/windows. And share your super python tool to the world (wuy comes with its own freezer (a wuy app !))!

Since 0.6; wuy provide a js method to proxify http requests, to avoid CORS troubles.

It's, a little bit, the same thing as python eel.

TODOs:

  • In the future : will use cefpython3 if it's present, else it will use the local chrome installation. (you could choose to force cef/local use) (you can already try ; modify wuy.py, replace ChromeApp() by ChromeAppCef())
  • Write docs & examples

The simplest example

This is the hello world of wuy

import wuy

class helloWorld(wuy.Window):
    """ <button onclick="wuy.beep()">BEEP</button> """
    size=(100,100)

    def beep(self):
        print("\a BEEP !!!")

helloWorld()

To Test/Run

Download the zip from here

$ pip3 install aiohttp winreg
$ python3 -u an_app.py

(winreg is needed for windows only)

It's an app !

For a regular server example (many clients from anywhere on web)

$ python3 -u a_server.py

To Use

Install the lib :

$ pip3 install wuy winreg

(winreg is needed for windows only)

And follow the official tuto.

See Examples

  • an_app : all kind of tricks
  • an_app2 : an input box
  • an_app3 : an alert box with autodeclared js vars (chain'able windows)!
  • an_app4 : using sync & async rpc calls !
  • an_app5 : using async aiohttp.get (request content from web) & FULLSCREEN mode
  • an_app6 : progress bars (async)
  • an_app7 : html is inside the docstring ! (SIMPLEST)
  • an_appVuejs : using a vuejs app (and a continuous push from server to client)
  • a_server : a server, tchat service for multiple clients

Don't forget to have a look at real examples too (real apps for real life)

With wuy.Window for app (which open/manage a chrome window app)

With wuy.Server for classic http/ws servers

And client side (javascript), in all cases : use wuy.js

Learn More on differences between this two class

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

wuy-0.8.9.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wuy-0.8.9-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file wuy-0.8.9.tar.gz.

File metadata

  • Download URL: wuy-0.8.9.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for wuy-0.8.9.tar.gz
Algorithm Hash digest
SHA256 4844bd9c3077ad86d8e6629c196bde6a506cc30b19fecb79acaa1b7e78b3cbfd
MD5 1a897f4c6416e52acabe618cd9690e69
BLAKE2b-256 16515a381c1c3426aaab1b9629cd79a0af1916be6c5bfb9b418f07a5c4cc2d0a

See more details on using hashes here.

File details

Details for the file wuy-0.8.9-py3-none-any.whl.

File metadata

  • Download URL: wuy-0.8.9-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for wuy-0.8.9-py3-none-any.whl
Algorithm Hash digest
SHA256 4f46f7d70a28b288bd4f382f8ab5d86963d56e1641b5a3fabe6674d49c8d0280
MD5 619555d69740e3d3c38af73c3cdbbcae
BLAKE2b-256 a7fefea503d062692d3643991096c007d1ee2b02c39a6b2588a48aa8140b4ace

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