Skip to content

Instantly share code, notes, and snippets.

@syrte
Created August 2, 2016 05:35
Show Gist options
  • Select an option

  • Save syrte/00dd4377b39b5a9f46e194c63a5ad6d3 to your computer and use it in GitHub Desktop.

Select an option

Save syrte/00dd4377b39b5a9f46e194c63a5ad6d3 to your computer and use it in GitHub Desktop.
hide_cell_number

This extension allows hiding all cell numbers of a notebook. This can be achieved by clicking on the button toolbar:

Internals

The codecell hiding state is stored in the metadata IPython.notebook.metadata.hide_prompt. If it is set to true, all cell number will be hidden on reload.

Type: IPython Notebook Extension
Compatibility: 3.x 4.x
Main: main.js
Name: Hide cell number
Description: "toggle number of all cells"
// toggle display of all cells' number
define([
'jquery',
'base/js/namespace'
], function(
$,
IPython
) {
"use strict";
function set_number_visible(show) {
IPython.notebook.metadata.hide_prompt = show;
if (show) $('div.prompt').show('slow');
else $('div.prompt').hide('slow');
var btn = $('#toggle_numbers');
btn.toggleClass('active', !show);
var icon = btn.find('i');
icon.toggleClass('fa-chevron-left', show);
icon.toggleClass('fa-chevron-right', !show);
$('#toggle_numbers').attr(
'title', (show ? 'Hide' : 'Show') + ' cell numbers');
}
function toggle() {
set_number_visible($('#toggle_numbers').hasClass('active'));
}
var load_ipython_extension = function() {
IPython.toolbar.add_buttons_group([{
id : 'toggle_numbers',
label : 'Hide cell numbers',
//icon : 'fa-list-ol',
icon : 'fa-chevron-left',
callback : function() {
toggle();
setTimeout(function() { $('#toggle_numbers').blur(); }, 500);
}
}]);
set_number_visible(IPython.notebook.metadata.hide_prompt === true);
};
return {
load_ipython_extension : load_ipython_extension
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment