Skip to main content

A little Python library for making simple HTML/JS GUI apps

Project description


A little, zero-dependency Python library for making simple HTML/JS GUI apps


Note that only Python >= 3.6 is supported

pip install webevents

Example: ping-pong

Python sends a number to Javascript, which outputs it out to console, increments it and sends the number back to Python for displaying in terminal. And so on.

We will have the directory structure presented below. Generally speaking, In the "web" folder you can put your HTML/CSS/JS application. "Ping-pong" application will only consist of one "index.html" file.

└── web
    └── index.html


<!DOCTYPE html>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Webevents "Ping-pong"</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <script src="webevents.js"></script>
  Demonstration in console
  webevents.addEventListener("ping", function(number){
    webevents.fireEvent("pong", number+1);

import webbrowser
import webevents

def pong_callback(number):
    snakes_events.fire_event("ping", int(number) + 1)

address = ("localhost", 8080)
snakes_events =, "web")
snakes_events.add_termination_callback(lambda: print("The end!"))
snakes_events.add_event_listener("pong", pong_callback)


# initial ping
snakes_events.fire_event("ping", 0)

    while True:
except KeyboardInterrupt:

Multiple callbacks are supported. You can remove events with:

  • remove_event_listener(event_type, callback) in Python
  • removeEventListener(event_type, callback) in JS

In Python you can add termination callbacks with add_termination_callback(callback). It may be useful in multi process applications. Note that there is no need to add termination callbacks if you don't need them.

Usually termination is occurred when user closes the browser page. But you can disable this by passing timeout=None in You always can terminate the "webevents" with webevents.terminate().

Javascript output:

0 2 4 6 8 10 12 ...

Python output:

1 3 5 7 9 11 13 ... The end!

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

webevents-0.1.4.tar.gz (4.5 kB view hashes)

Uploaded source

Built Distribution

webevents-0.1.4-py3-none-any.whl (5.0 kB view hashes)

Uploaded py3

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