Skip to content

Instantly share code, notes, and snippets.

@FinanceData
Forked from jamesbishopca/code_toggle.py
Created July 22, 2016 05:05
Show Gist options
  • Save FinanceData/9ccb953716e26b0d091dc35bacefd018 to your computer and use it in GitHub Desktop.
Save FinanceData/9ccb953716e26b0d091dc35bacefd018 to your computer and use it in GitHub Desktop.
Code toggle button for IPython notebook
'''Creates a button to toggle code inputs on and off.'''
from IPython.core.display import display_html
di.display_html('''
<script>
'use strict';
function code_toggle() {
let code = $('div.input');
code.css('display') == 'none' ? code.show() : code.hide();
}
$(document).ready(function() {
$('div.input').hide();
});
</script>
''', raw=True)
di.display_html('<button onclick="code_toggle()">Toggle Code</button>', raw=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment