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?
For extra protection, before making the cell not Editable , you may wish to make it not Deletable . To do so, select the cell, open the Option Inspector, and uncheck Deletable in the Cell Options > General Properties section. (And while you're there you can then also uncheck Editable .)
Locked cells in Jupyter notebooks To confirm, hit the Edit button and exit the pop-up. These cells are now still runnable but can't be edited or deleted anymore. Once you're done editing all the cells that you want to lock, disable the Edit Metadata again by going to View > Cell Toolbar , and selecting None .
Yes, Use the steps below
@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.
Source
There is an extension for IPython that is supposed to that:
Read Only Cell extension.
Getting it to work is something else, but it is there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With