Reputation: 5700
Is there a way to mark a cell in the ipython/jupyter notebook readonly using the json format in the ipynb file? (E.g., a cell attribute "readonly":false
or some such.) If not, is there a jquery hack to find suppress the double click event in the cell?
Upvotes: 33
Views: 33864
Reputation: 741
Yes, Use the steps below:
true
or false
to get the desired effect.The JSON will look something like this:
{
"deletable": false,
"editable": false,
"scrolled": true,
"trusted": true
}
Upvotes: 24
Reputation: 1105
@Richard Ackon's answer requires adjustments for JupyterLab:
Open the Property Inspector.
Focus the cell you want to lock.
Add the following lines to the Cell Metadata:
{
"trusted": true,
"editable": false,
"deletable": false
}
Click on the tick to save the metadata... Tadah!, your cell can't be modified or deleted.
The Property Inspector comes built-in since JupyterLab 2.0 (note it was moved to the right sidebar by default in JupyterLab 3.0). For older JupyterLab versions you would need to modify the notebook file manually.
Unfortunately, the outputs can still be cleared by intentionally selecting that option in the menu bar (Edit
> Clear Ouputs
). Of course that can only happen if you DO WANT to clear the outputs and not just update them by running the cell.
Upvotes: 30
Reputation: 28878
There is an extension for IPython that is supposed to that:
Getting it to work is something else, but it is there.
Upvotes: 3