[IPython-dev] 2 questions about notebooks : disabling cells for edition and best hiding menu bar process

Matthias BUSSONNIER bussonniermatthias at gmail.com
Wed May 28 09:49:27 EDT 2014

Le 28 mai 2014 à 15:22, Benjamin Ninassi a écrit :

> Thanks a lot for your quick answears !
> It should be possible by directly setting the read-only mode to some cell in CodeMiror itself, but it will require a bit of javscript:
> http://codemirror.net/doc/manual.html#option_readOnly
> I'll drill into that, thanks ! My major issue will be to identify the cells that i want to disable through the DOM as they have no ID ... is-it possible to give them one with metadata ?

You cannot (yet) get a dom identity through the metadata, but you can a list of sell by 


then loop on all cell and on each cell do approximatively a

var ro = (cell.metadata.my_namespace || {}).readonly

if(ro === true):

Which should do the desired effect.
You might want to capture a few other event like execution request on theses cell by monkey patching
the CellClass.prototype.execute

CellClass.prototype.old_execute = CellClass.prototype.execute
CellClass.prototype.execute = function(){
	if not read only :


> I suppose css with the same target and display:none in custom.css should works.
> I was supposing that to, but there is a  style="display: block;" generated in the html for the header div that overwrite the custom.css  
> #header{   display:none; } …

Hum, we should probably fix that then.

> No, there is no list. You can grep through the source for IPython.events out should give yo an idea of existing event, 
> The rest depend if when using IPython for a MOOC you will be providing the sever,in which case you can customize it a lot 
> or if you plan on users to install IPython in which case you probably want to avoid too aggressive customization. 
> We will be providing a server, so we can customize it a lot. I'm convince ipython and notebooks are great tools for online education, providing some minor adjustments !

Then you can probably apply a patch on the template to remove whatever element for the time being. 
We'll be happy to get your feedback from using the notebook for teaching.


More information about the IPython-dev mailing list