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
Save this script to a file called `example.py`. You can then run::
212
-
213
-
$ ipywidgets-server example:container
214
-
215
-
.. image:: images/matplotlib-sine.png
216
-
217
-
It is worth noting the following:
218
-
219
-
- we wrap the application into a controller class responsible both for generating the view and for reacting to user actions. Using a class provides better encapsulation and re-use.
220
-
- in the class constructor, we handle rendering the static components of the view. We create two container widgets, one to hold the sliders and one to hold the plot. We stack these two containers in an ``HBox``, the top level widget holding our application.
221
-
- We handle reacting to changes in the sliders by `observing` the ``value`` traitlet of the slider. The ``.observe`` method takes a callback as first argument. The callback that we pass in just re-renders the plot. The second argument to ``.observe`` is a list of attributes of the slider to observe. We only want to react to changes in the slider value (rather than, say, its maximum or minimum).
222
-
- The ``render`` method of our application renders the dynamic components and returns the top level widget.
0 commit comments