Async Web Framework
Project description
Dazzler
Dazzler is a hybrid UI framework for Python to create Desktop or Web Applications.
Built with Aiohttp, React and Electron.
Install
Install with pip: $ pip install dazzler
Features
- Fast WebSocket based communication, deliver updates in realtime to thousands of connected clients at once.
- Build desktop applications with Electron.
- Support for third party integrations via middlewares.
- Session & authentication systems.
- Tie & Transform API to perform updates on the client side.
Quickstart
Quickstart with a GitHub template
Example
Create a page with a layout and assign bindings to save & load a visitor name with the session system. The button to save the visitor name is disabled if no input value via tie & transform.
from dazzler import Dazzler
from dazzler.system import Page, BindingContext, CallContext, transforms as t
from dazzler.components import core
app = Dazzler(__name__)
page = Page(
__name__,
core.Container([
core.Html('H2', 'My dazzler page'),
core.Container('Please enter a name', identity='visitor-name'),
core.Input(value='', identity='input'),
core.Button('Save name', identity='save-btn', disabled=True),
], identity='layout', id='layout'),
title='My Page',
url='/'
)
# UI updates via tie & transforms
page.tie('value@input', 'disabled@save-btn').transform(
t.Length().t(t.Lesser(1))
)
# Bindings executes on the server via websockets.
@page.bind('clicks@save-btn')
async def on_click(context: BindingContext):
# Save the visitor name via session system
name = await context.get_aspect('input', 'value')
await context.session.set('visitor', name)
await context.set_aspect(
'visitor-name', children=f'Saved {name}'
)
# Aspects defined on the layout trigger on initial render and
# allows to insert initial data.
# `call` executes via regular requests.
@page.call('id@layout')
async def on_layout(context: CallContext):
visitor = await context.session.get('visitor')
if visitor:
await context.set_aspect(
'visitor-name', children=f'Welcome back {visitor}!'
)
app.add_page(page)
if __name__ == '__main__':
app.start()
Documentation
Full documentation hosted on readthedocs.
Get help for the command line tools: $ dazzler --help
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
dazzler-0.10.0-py3-none-any.whl
(10.6 MB
view details)
File details
Details for the file dazzler-0.10.0-py3-none-any.whl
.
File metadata
- Download URL: dazzler-0.10.0-py3-none-any.whl
- Upload date:
- Size: 10.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 198549c7fde994cecae782781bf997a60ae163eb0d2448e2c2bef439599595f9 |
|
MD5 | e833c3f4df651e13fca9ea88ab108eb8 |
|
BLAKE2b-256 | 36cbf5eeeec63560fec39b90961ec819a37c12ac5fcb7154e523c6dddc630539 |