Skip to content

T4rk1n/dazzler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

69c4942 · Dec 6, 2021
Nov 28, 2021
Aug 31, 2021
Dec 6, 2021
Dec 6, 2021
Dec 6, 2021
Dec 6, 2021
Jun 18, 2019
Oct 22, 2021
Apr 5, 2020
Nov 14, 2021
Sep 5, 2019
Jun 20, 2021
Dec 4, 2021
Oct 20, 2021
Jun 18, 2019
Nov 28, 2021
Nov 28, 2021
Dec 4, 2021
Oct 22, 2021
Jul 4, 2021
Sep 5, 2019
Nov 28, 2021
Nov 13, 2021
Aug 1, 2021
Dec 4, 2021
Dec 4, 2021
Nov 28, 2021
Nov 28, 2021
Nov 28, 2021
Nov 28, 2021
Nov 28, 2021
Jul 16, 2021
Jun 16, 2021
Nov 24, 2021
Aug 31, 2021
Aug 31, 2021
Jul 15, 2021

Repository files navigation

Dazzler

Build Documentation Status Version License

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