ipython notebook: how to toggle header invisible by default

戏子无情 提交于 2019-12-03 13:33:05
  1. If it doesn't already exist, create a file named custom.js in /Users/YOURUSERNAME/.ipython/profile_default/static/custom/
    (You may have to run ipython profile create, if you have never run this command.)

  2. In custom.js, put the following lines of JavaScript

    $([IPython.events]).on("app_initialized.NotebookApp", function () {
        $('div#header').hide();
    });
    
  3. If you would like to also hide the toolbar by default, use these lines of JavaScript instead

    $([IPython.events]).on("app_initialized.NotebookApp", function () {
        $('div#header').hide();
        $('div#maintoolbar').hide();
    });
    
chbrown

If you have a recent IPython, like v3.0.0 or higher, and are seeing only sporadic success with this method, you'll need to hook into the RequireJS dependency loader, and put the following in your common.js:

require(['jquery'], function($) {
  $('#header-container').hide();
});

common.js is loaded at the bottom of the page, so there's no need to wait for the DOM ready event, i.e., $(function() { ... }).

For further discussion see my answer at Turn off auto-closing parentheses in ipython and its comments.

176coding

if you are using Anaconda3, please do:

  1. update your C:\Anaconda3\Lib\site-packages\notebook\static\custom\custom.css

    .container{ width:100% !important; }
    div#site{ height: 100% !important; }
    
  2. update your C:\Anaconda3\Lib\site-packages\notebook\static\custom\custom.js, and we add a shortcut ctrl+ for toggle the header

    $([IPython.events]).on('notebook_loaded.Notebook',function(){
        $('#header').hide();
        IPython.keyboard_manager.command_shortcuts.add_shortcut('ctrl-`',function (event) {
            if (IPython.notebook.mode == 'command') {
                $('#header').toggle();
                return false;
            }
            return true;
        });
    });
    
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!