I'd like to do exacly what has been asked and answered in the post How can I hide code and rerun all cells in a jupyter notebook? but in JupyterLab. A while back, this just didn't seem to be possible. But after the release of v0.33 I believe it should be possible since:
Javascript execution in notebook cells has been re-enabled
But If i try to run the script below, the only thing that happens in JupyterLab is that this output is produced:
Output:
Button(description='Refresh', style=ButtonStyle())
Code:
from IPython.display import HTML
HTML('''<script>
function code_toggle() {
if (code_shown){
$('div.input').hide('500');
$('#toggleButton').val('Show code')
} else {
$('div.input').show('500');
$('#toggleButton').val('Hide code')
}
code_shown = !code_shown
}
$( document ).ready(function(){
code_shown=false;
$('div.input').hide()
});
</script>
<form action="javascript:code_toggle()"><input type="submit" id="toggleButton" value="Show code"></form>''')
from IPython.display import Javascript, display
from ipywidgets import widgets
def run_all(ev):
display(Javascript('IPython.notebook.execute_cells_below()'))
button = widgets.Button(description="Refresh")
button.on_click(run_all)
display(button)
So, does anyone know if this should be possible in JupyterLab?