import jupyter_drawing_pad as jd
import matplotlib.pyplot as plt
The widget is a box containing a drawing pad (main widget) and buttons (related to functionalities described below). Here is the drawing pad. You can draw whatever you want and data will be synchronised with the Python.
widget = jd.CustomBox()
widget.drawing_pad
Failed to display Jupyter Widget of type DrawingPad
.
If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean that the widgets JavaScript is still loading. If this message persists, it likely means that the widgets JavaScript library is either not installed or not enabled. See the Jupyter Widgets Documentation for setup instructions.
If you're reading this message in another frontend (for example, a static rendering on GitHub or NBViewer), it may mean that your frontend doesn't currently support widgets.
print(widget.drawing_pad.data)
[[], [], []]
Synchronisation works both ways !
widget.drawing_pad.data = [ [100,200,300], [100,20,30], [1,2,3]]
You can display the entiere widget. There are four additionnal elements:
Welcome (name)
should appearwidget
Failed to display Jupyter Widget of type CustomBox
.
If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean that the widgets JavaScript is still loading. If this message persists, it likely means that the widgets JavaScript library is either not installed or not enabled. See the Jupyter Widgets Documentation for setup instructions.
If you're reading this message in another frontend (for example, a static rendering on GitHub or NBViewer), it may mean that your frontend doesn't currently support widgets.
Accessing registered signatures
print(widget.get_saved())
{}
Reproducing the content of the drawing pad in a figure using matplotlib
plt.figure(figsize=(10,5))
plt.plot(widget.drawing_pad.data[0], widget.drawing_pad.data[1])
plt.xlim(0,500)
plt.ylim(0,250)
plt.show()