You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: jupyter-widgets-schema/messages.md
+6-23Lines changed: 6 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -210,7 +210,7 @@ In order to display widgets in both the classic notebook and JupyterLab, ipywidg
210
210
211
211
212
212
213
-
# Widget messaging protocol, version 2
213
+
# Widget messaging protocol, version 2 (not finalized)
214
214
215
215
A Jupyter widget has both a frontend and kernel object communicating with each other using the `comm` messages provided by the Jupyter kernel messaging protocol. The primary communication that happens is synchronizing widget state, represented in the messages by a dictionary of key-value pairs. The Jupyter widget messaging protocol covers `comm` messages for the following actions:
216
216
@@ -227,6 +227,8 @@ Throughout this document, relevant parts of messages to the discussion are quote
227
227
228
228
The `jupyter.widget.version` comm target and associated version validation messages are gone. Instead, it is up to the package maintainers to ensure that the versions of the packages speak the same widget message protocol. We encourage kernel and frontend package developers to clearly indicate which protocol version the package supports.
229
229
230
+
The sync update event from the frontend to the kernel was restructured to have the same field names as the event from the kernel to the frontend, namely the method field is `'update'` and the state data is in the `state` attribute.
231
+
230
232
## Implementating the Jupyter widgets protocol in the kernel
231
233
232
234
In this section, we concentrate on implementing the Jupyter widget messaging protocol in the kernel.
@@ -275,9 +277,9 @@ The type of widget to be instantiated in the frontend is determined by the `_mod
275
277
276
278
### State synchronization
277
279
278
-
#### Synchronizing from kernel to frontend: `update`
280
+
#### Synchronizing widget state: `update`
279
281
280
-
When a widget's state changes in the kernel, the changed state keys and values are sent to the frontend over the widget's comm channel using an `update` message:
282
+
When a widget's state changes in either the kernel or the frontend, the changed state keys and values are sent to the other side over the widget's comm channel using an `update` message:
281
283
282
284
```
283
285
{
@@ -298,26 +300,7 @@ Comm messages for state synchronization may contain binary buffers. The optional
298
300
299
301
See the [Model state](modelstate.md) documentation for the attributes of core Jupyter widgets.
300
302
301
-
#### Synchronizing from frontend to kernel: `backbone`
302
-
303
-
When a widget's state changes in the frontend, the changed keys are sent to the kernel over the widget's comm channel using a `backbone` message:
304
-
305
-
```
306
-
{
307
-
'comm_id' : 'u-u-i-d',
308
-
'data' : {
309
-
'method': 'backbone',
310
-
'sync_data': { <dictionary of widget state> }
311
-
'buffer_keys': [ <optional list of state keys corresponding to binary buffers in the message> ]
312
-
}
313
-
}
314
-
```
315
-
316
-
The state update is split between values that are serializable with JSON (in the `data.sync_data` dictionary), and binary values (represented in `data.buffer_keys`).
317
-
318
-
The `data.sync_data` value is a dictionary of widget state keys and values that can be serialized to JSON.
319
-
320
-
Comm messages for state synchronization may contain binary buffers. The `data.buffer_keys` optional value contains a list of keys corresponding to the binary buffers. For example, if `data.buffer_keys` is `['x', 'y']`, then the first binary buffer is the value of the `'x'` state attribute and the second binary buffer is the value of the `'y'` state attribute.
303
+
TODO: update protocol for changes in https://github.com/ipython/ipywidgets/pull/1194
0 commit comments