Package: wuy
wuy( You should considerGUY(when available)! )If you have made asuper 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 bywuy.html/pythonBasically, 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 marvellousaiohttp, and (if present) theuvloop, 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)Inapp/window mode: it will manage (open/close) the window for you ; using thechrome 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 !Inserver 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 differencesIn all cases : it will be pretty easy to produce/freeze an executable (windows/linux/apple) (one file with all html/js embedded), usingpyinstaller/windows. And share yoursuper python toolto the world (wuy comes withits own freezer (a wuy app !))! And in the future : android !Since 0.6;wuyprovide a js method toproxify http requests, to avoid CORS troubles.Since 0.9;wuyprovide get/set methods on client/server side to store/retrieve key/value pairs in a json file on serverside.It's, a little bit, the same thing aspython eel.TODOs:In the future :cefpython3will be the platform of choice for runningwuyapps onandroid/iphone (whencefandcefpython3will be ready). Currentlywuyworks with cefpython3, on linux/windows/apple. It's working in theunittests suite(you can already try ; modifywuy.py, replace ChromeApp() by ChromeAppCef())Write docs & examplesThe simplest exampleThis isthe hello worldofwuyimportwuyclasshelloWorld(wuy.Window):""" <button onclick="wuy.beep()">BEEP</button> """size=(100,100)defbeep(self):print("\aBEEP !!!")helloWorld()To Test/RunDownloadthe zip from here$ pip3 install aiohttp winreg
$ python3 -u an_app.py(winregis needed for windows only)It's an app !For a regular server example (many clients from anywhere on web)$ python3 -u a_server.pyTo UseInstall the lib :$ pip3 install wuy winreg(winregis needed for windows only)And follow theofficial tuto.See Examplesan_app: all kind of tricksan_app2: an input boxan_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 modean_app6: progress bars (async)an_app7: html is inside the docstring ! (SIMPLEST)an_app8: just to show how to organize your code when app's expand.an_appVuejs: using a vuejs app (and  a continuous push from server to client)a_server: a server, tchat service for multiple clientsan_upload: a drag'n'drop upload to server example.Don't forget to have a look atreal examplestoo (real apps for real life)A big real life app : SeejBrout3(in development), it's the rebirth of the good old py2/gtk app :jBrout2. It use vuejs/vuex for front, and the jbrout's lib to manage photos.DocUsewuy.Windowfor app (which open/manage a chrome window app)Usewuy.Serverfor classic http/ws serversAnd client side (javascript), in all cases : usewuy.jsLearn More on differences between this two class