Widgets wrapper
The ipywidgets
package provides a good interface to create widgets wrappers in Python, and interact between them.
Some widgets can be used for layout.
Some CSS properties can even be set.
Beware: widgets are unique, so editing them after displaying will change what has been displayed previously. Don't display
them twice, or you will duplicate them!
Custom widget
Sometimes you may want to create a custom Widget, with a custom Javascript.
Python back-end
In the Python back-end, we will define a class and some attributes so that Jupyter can link it with the Javascript front-end.
Javascript front-end
In the Javascript front end we define what we need, and create a module to match our Python.
Now we just have to instanciate it in Python.
Now the Python is linked to the Javascript:
We can even link it with other widgets:
A note about Javascript
Javascript can be executed by using the magic %%javascript
or the Javascript display:
The current node output is designated by element
: