Skip to content

Commit f14dd5e

Browse files
committed
Additional explanation for pre IPython 4.x use
1 parent 2e71ecc commit f14dd5e

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

notebooks/chapter03_notebook/03_controls.ipynb

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"cell_type": "markdown",
1919
"metadata": {},
2020
"source": [
21-
"The CSS and Javascript of the HTML notebook can be customized through the files in `~/.ipython/profile_default/static/custom`, where `~` is your `HOME` directory, and `default` is your IPython profile. In this short recipe, we will use this feature to add a new button in the notebook toolbar on top of every notebook. Specifically, this button renumbers linearly all code cells."
21+
"The CSS and Javascript of the HTML notebook can be customized through the files in `~/.jupyter/custom` directory, where `~` is your `HOME` directory, (if you are using IPython < 4.x, the location is `~/.ipython/profile_default/static/custom`, where `default` is your IPython profile). In this short recipe, we will use this feature to add a new button in the notebook toolbar on top of every notebook. Specifically, this button renumbers linearly all code cells."
2222
]
2323
},
2424
{
@@ -39,26 +39,28 @@
3939
"%%javascript\n",
4040
"// This function allows us to add buttons \n",
4141
"// to the notebook toolbar.\n",
42-
"IPython.toolbar.add_buttons_group([\n",
42+
"// If using IPython < 4.x, replace 'Jupyter' everywhere below\n",
43+
"// with 'IPython'\n",
44+
"Jupyter.toolbar.add_buttons_group([\n",
4345
"{\n",
4446
" // The button's label.\n",
4547
" 'label': 'renumber all code cells',\n",
4648
" \n",
4749
" // The button's icon.\n",
4850
" // See a list of Font-Awesome icons here:\n",
4951
" // http://fortawesome.github.io/Font-Awesome/icons/\n",
50-
" 'icon': 'fa-list-ol',\n",
52+
" 'icon': 'fa-list-ol', // 'icon-list-ol' for older IPython\n",
5153
" \n",
5254
" // The callback function.\n",
5355
" 'callback': function () {\n",
5456
" \n",
5557
" // We retrieve the lists of all cells.\n",
56-
" var cells = IPython.notebook.get_cells();\n",
58+
" var cells = Jupyter.notebook.get_cells();\n",
5759
" \n",
5860
" // We only keep the code cells.\n",
5961
" cells = cells.filter(function(c)\n",
6062
" {\n",
61-
" return c instanceof IPython.CodeCell; \n",
63+
" return c instanceof Jupyter.CodeCell; \n",
6264
" })\n",
6365
" \n",
6466
" // We set the input prompt of all code cells.\n",
@@ -80,38 +82,38 @@
8082
"cell_type": "markdown",
8183
"metadata": {},
8284
"source": [
83-
"2. To make these changes permanent, i.e. to add this button on every notebook, we can open (or create, if necesary) the file `~/.jupyter/custom/custom.js` (for IPython before 4.0.0 use `~/.ipython/profile_default/static/custom/custom.js`) and add the following code:"
85+
"2. To make these changes permanent, i.e. to add this button on every notebook, we can open (or create, if necesary) the file `~/.jupyter/custom/custom.js` and add the code below. For IPython before 3.x and older, use file `~/.ipython/profile_default/static/custom/custom.js` and replace all occurences of `Jupyter` in the code with `IPython`."
8486
]
8587
},
8688
{
8789
"cell_type": "markdown",
8890
"metadata": {},
8991
"source": [
9092
"```javascript\n",
91-
"$([IPython.events]).on('app_initialized.NotebookApp',\n",
93+
"$([Jupyter.events]).on('app_initialized.NotebookApp',\n",
9294
" function(){\n",
9395
"\n",
9496
" // Copy of the Javascript code above (step 1).\n",
95-
" IPython.toolbar.add_buttons_group([\n",
97+
" Jupyter.toolbar.add_buttons_group([\n",
9698
" {\n",
9799
" // The button's label.\n",
98100
" 'label': 'renumber all code cells',\n",
99101
"\n",
100102
" // The button's icon.\n",
101103
" // See a list of Font-Awesome icons here:\n",
102104
" // http://fortawesome.github.io/Font-Awesome/icons/\n",
103-
" 'icon': 'fa-list-ol',\n",
105+
" 'icon': 'fa-list-ol', // 'icon-list-ol' for older IPython\n",
104106
"\n",
105107
" // The callback function.\n",
106108
" 'callback': function () {\n",
107109
"\n",
108110
" // We retrieve the lists of all cells.\n",
109-
" var cells = IPython.notebook.get_cells();\n",
111+
" var cells = Jupyter.notebook.get_cells();\n",
110112
"\n",
111113
" // We only keep the code cells.\n",
112114
" cells = cells.filter(function(c)\n",
113115
" {\n",
114-
" return c instanceof IPython.CodeCell; \n",
116+
" return c instanceof Jupyter.CodeCell; \n",
115117
" })\n",
116118
"\n",
117119
" // We set the input prompt of all code cells.\n",

0 commit comments

Comments
 (0)