Built for beauty
and speed

Cross-platform LGPL-licensed desktop GUI framework for C and Rust, backed by the Mozilla WebRender rendering engine.

Rendering a simple UI using the Azul GUI toolkit
  • Memory: 23MB
  • CPU: 0%

The UI structure is created via composition instead of inheritance. Callbacks can modify the application data and then tell the framework to reconstruct the entire UI again - but only if it's necessary, not on every frame.

from azul import *

css = """
    .__azul-native-label { font-size: 50px; }
"""

class DataModel:
    def __init__(self, counter):
        self.counter = counter

# model -> view
def my_layout_func(data, info):
    label = Label("{}".format(data.counter))
    button = Button("Update counter")
    button.set_on_click(data, my_on_click)

    dom = Dom.body()
    dom.add_child(label.dom())
    dom.add_child(button.dom())

    return dom.style(Css.from_string(css))

# model <- view
def my_on_click(data, info):
    data.counter += 1;

    # tell azul to call the my_layout_func again
    return Update.RefreshDom

model = DataModel(5)
app = App(model, AppConfig(LayoutSolver.Default))
app.run(WindowCreateOptions(my_layout_func))