Skip to content

Runners

The 'Runners' is the htag denomination, for some classes provided with htag, to help you to run a Htag App in a context. Here are the current provided runners, and could give you ideas of what you want ;-)

htag provides officialy 3 runners :

  • Runner : the base one, for desktop app
  • PyScript : the special to be runned in pure html side
  • PyWebView : a specific for desktop using a CEF UI (using pywebview) ... (it could be in another htag module soon)

If you want to create an "Android app" (smartphone, tv, etc ...) see htagapk recipes)

If you want to create an "Web app" (multiple clients) see htagweb runner)

Between 0.90 & 1.0 versions, htag provides the old runners (for compatibility reasons), but they are deprecated and will be removed at 1.0. Here they are:

  • AndroidApp
  • BrowserHTTP
  • BrowserStarletteHTTP
  • BrowserStarletteWS
  • ChromeApp
  • DevApp
  • BrowserTornadoHTTP
  • WinApp

Currently, all are faked/simulated and use the new Runner instead (thus, a runner like BrowserStarletteWS, doesn't use starlette anymore, but the new runner home-made server, which is enough robust for one client/user ;-) )

Runner 'Runner'

This runner can simulate all old runners. All specialized features, that were in some runners only, are all available now. This runner is a pure python server (holding Websocket/HTTP connexions). Things like uvicorn/starlette/tornado were overbloated for a server which can handle one client ;-)

See Runner

Runner 'PyScript'

Run everything in client side, thanks to the marvellous pyscript. Don't know if there is an utility, but it's possible ;-). It should run OOTB, everywhere where pyscript runs.

Run your App (htag.Tag class), in a HTML file, like this :

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
    <script defer src="https://pyscript.net/latest/pyscript.js"></script>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <py-config>
    packages = ["htag"]
    </py-config>
</head>
<body> loading pyscript ;-)
<py-script>
###############################################################################
from htag import Tag

class App(Tag.body):
    ...

###############################################################################
from htag.runners import PyScript
PyScript( App ).run()

</py-script>
</body>
</html>

source

Pros

  • you only need a browser ;-)
  • Interactions are INPROC.
  • no need of external libs

Cons

  • Launching the pyscript environnement can be long.

Runner 'PyWebView'

Run everything in a pywebview instance. The ideal solution to provide a "python GUI app".

Run your App (htag.Tag class) like this :

from htag.runners import PyWebView
PyWebView( App ).run()

source

Pros

  • Interactions are INPROC.
  • the app can self.exit()

Cons