browsergui package

Module contents

Tools for building GUIs that use a browser as the front-end.

elements Defines many types of GUI elements.
events Defines Events that represent actions taken by the user.
GUI(*elements, **kwargs) Manages high-level features of the UI and coordinates between elements.
class browsergui.GUI(*elements, **kwargs)[source]

Manages high-level features of the UI and coordinates between elements.

Useful attributes/methods:

See this wiki page for a guide to the basics.

Parameters:
  • elements (Element) – elements to immediately include in the GUI
  • title (str) – title of the GUI (i.e. title of browser tab)
body

A Container that contains all the Elements you put into the GUI.

Since Containers are mutable sequences, the following all do what you’d expect:

>>> gui.body.append(e)
>>> gui.body.extend([e1, e2, e3, e4])
>>> gui.body[3] = e5
>>> del gui.body[0]
dispatch_event(event)[source]

Dispatch an event to whatever element is responsible for handling it.

run(open_browser=True, port=None, quiet=False)[source]

Displays the GUI, and blocks until Ctrl-C is hit or stop_running() is called.

Raises a RuntimeError if the GUI is already running.

Parameters:
  • open_browser (bool) – whether to open a browser tab for the GUI
  • port (int) – which port to start the HTTP server on (None for “don’t care”)
  • quiet (bool) – whether to silence normal the server’s normal logging to stderr.
stop_running()[source]

Stops displaying the GUI.

Raises a RuntimeError if the GUI is not running.

title

The title for the browser page.