Demo for jupyter-drawing-pad widget


In [1]:
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.


In [2]:
widget = jd.CustomBox()
widget.drawing_pad



In [3]:
print(widget.drawing_pad.data)


[[], [], []]

Synchronisation works both ways !


In [4]:
widget.drawing_pad.data = [ [100,200,300], [100,20,30], [1,2,3]]

You can display the entiere widget. There are four additionnal elements:

  • a text-field : to enter a name related to a signature (drawn in the drawing pad)
  • a Clear button
  • a Save button : to save a signature (related to the name written in the text field)
  • a Login button : you can try to reproduce a signature previously registered. If this signature is close enough to one of the saved ones, a message Welcome (name) should appear

In [5]:
widget


Accessing registered signatures


In [6]:
print(widget.get_saved())


{}

Reproducing the content of the drawing pad in a figure using matplotlib


In [7]:
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()



In [ ]: