Snap - partir d'un projet existant¶

Snap ou Scratch dans un notebook. On s'assure d'abord que les fichiers javascript de Snap sont accessibles depuis le serveur IPython :

In [1]:
from code_beatrix.jsscripts import copy_jstool2notebook
%load_ext code_beatrix
copy_jstool2notebook("snap")
Out[1]:
[('>+',
  <pyquickhelper.filehelper.file_tree_node.FileTreeNode at 0x2981ff1f518>,
  'c:\\Python36_x64\\lib\\site-packages\\notebook-5.0.0-py3.6.egg\\notebook\\static\\snap'),
 ('>+',
  <pyquickhelper.filehelper.file_tree_node.FileTreeNode at 0x2981ff51320>,
  'c:\\Python36_x64\\lib\\site-packages\\notebook-5.0.0-py3.6.egg\\notebook\\static\\snap'),
 ('>+',
  <pyquickhelper.filehelper.file_tree_node.FileTreeNode at 0x2981ff35da0>,
  'c:\\Python36_x64\\lib\\site-packages\\notebook-5.0.0-py3.6.egg\\notebook\\static\\snap'),
 ('>+',
  <pyquickhelper.filehelper.file_tree_node.FileTreeNode at 0x2981ffaca58>,
  'c:\\Python36_x64\\lib\\site-packages\\notebook-5.0.0-py3.6.egg\\notebook\\static\\snap'),
 ('>+',
  <pyquickhelper.filehelper.file_tree_node.FileTreeNode at 0x2981ffacf60>,
  'c:\\Python36_x64\\lib\\site-packages\\notebook-5.0.0-py3.6.egg\\notebook\\static\\snap'),
 ('>-',
  None,
  <pyquickhelper.filehelper.file_tree_node.FileTreeNode at 0x2982003dd68>)]

Si le résultat est une liste vide, cela signifie que cela a déjà été fait.

In [2]:
%snap --help
usage: snap [-h] [-f FILE] [-d DIV] [-W WIDTH] [-H HEIGHT]

insert a snap window inside a notebook

optional arguments:
  -h, --help            show this help message and exit
  -f FILE, --file FILE  scratch or snap file to display
  -d DIV, --div DIV     id for the HTML div
  -W WIDTH, --width WIDTH
                        window width
  -H HEIGHT, --height HEIGHT
                        window height
usage: snap [-h] [-f FILE] [-d DIV] [-W WIDTH] [-H HEIGHT]

In [3]:
# pas encore parfait, il faut mieux utiliser l'autre notebook.
from code_beatrix.jsscripts.nbsnap import RenderSnap
RenderSnap()
Out[3]:
Snap showing up soon...
In [4]:
%snap
Out[4]:
Snap showing up soon...
In [5]: