Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Binder

Link a source widget’s trait into a target’s, with an optional linear transform (multiplier/offset) or a nested dotted-path target.

Import

from manywidgets import Binder

Example

Drag the slider — the chart’s width follows value × 100:

import numpy as np
from manywidgets import Slider, Chart, Binder

x = np.linspace(0, 10, 100)
chart = Chart(title="sin")
chart.add_series(x=x, y=np.sin(x), name="sin")

width = Slider(label="Width", min=4, max=12, value=8)
binder = Binder(source=width, source_field="value",
                target=chart, target_field="width", multiplier=100)

display(width, chart, binder)

API

TraitTypeDefaultDescription
source_widget_idUnicode''widget_id of the source widget.
source_fieldUnicode'value'Source trait to read.
target_widget_idUnicode''widget_id of the target widget.
target_fieldUnicode''Target trait/dotted-path to write (e.g. ‘view_state.zoom’).
multiplierFloat1.0Linear transform multiplier.
offsetFloat0.0Linear transform offset.
labelUnicode''Optional status label.
widget_idUnicode''Stable unique id used for cross-widget linking (auto-assigned).

Binder covers what jslink/jsdlink can’t: a linear transform on the value, or writing a nested dotted-path target (e.g. target_field="view_state.zoom"), merged into the parent dict. For plain pass-through links, prefer jslink — see the linking guide.