Widgets API

All widget functions return a WidgetHandle with:

ww.button(label, on_click=None)

Clickable button. Use .on_click decorator or pass on_click directly.

btn = ww.button("Click me")

@btn.on_click
def clicked():
    print("Button was clicked!")

ww.input(label, placeholder="", value="")

Single-line text input.

name = ww.input("Your name", placeholder="Enter name")

ww.textarea(label, rows=4, value="")

Multi-line text area.

ww.slider(label, min=0, max=100, value=50, step=1)

Numeric slider.

s = ww.slider("Temperature", min=0, max=100, value=20)

@s.on_change
def on_temp(val):
    print(f"Temperature: {val}")

ww.select(label, options, value=None)

Dropdown select.

options : list[str]
Available choices.
value : str | None
Initial selection. Defaults to first option.
color = ww.select("Color", ["Red", "Green", "Blue"])

ww.checkbox(label, value=False)

Boolean checkbox.

ww.radio(label, options, value=None)

Radio button group.

ww.number(label, min=0, max=100, step=1, value=0)

Numeric input with spinner.

ww.date_picker(label, value="")

Date input field.

ww.color_picker(label, value="#3366cc")

Color picker input.

ww.file_upload(label, accept="")

File upload widget.

accept : str
MIME type filter (e.g. ".csv,.json").

Callback Pattern

All widgets support the same callback pattern:

widget = ww.slider("Value", min=0, max=100, value=50)

# As decorator
@widget.on_change
def handler(value):
    print(f"New value: {value}")

# Or pass directly
def my_handler(value):
    print(f"New value: {value}")
widget.on_change(my_handler)