FAQ

Re: [IPython-User] Hide code cells in the notebook

Johan Beke
Nov 26, 2012 at 6:55 pm
Putting the following code in a markdown cell works fine for me:

<script type="text/javascript">
show=true;
function toggle(){
if (show){
$('div.input').hide();
}else{
$('div.input').show();
}
show = !show
}
</script>
<a href="javascript:toggle()" target="_self">toggle input</a>

Johan
reply

Search Discussions

2 responses

  • Raju Joseph at Nov 27, 2012 at 8:06 am
    Thanks a lot Johan. This is going to be most helpful.

    **NOOB question alert**
    Is there any way in which a markdown cell could be used to create an input
    form to accept variables/parameters?
    These variable values could then be used to pipe into the code in the
    IPython input cells.

    This along with "toggle input" would be very useful in building quick-fix
    applications or application prototypes. (especially custom reporting
    applications)
    Such a notebook created could then be safely shared with business
    teams (aka teams who go glassy eyed on seeing code that need to be meddled
    with)

    I believe raw input is currently not handled by IPython, hence not sure if
    that would prevent the creation of such a form.

    Seeking forgiveness in advance if the question was a stupid one.

    Many Thanks,
    Raju

    On Tue, Nov 27, 2012 at 12:25 AM, Johan Beke wrote:

    Putting the following code in a markdown cell works fine for me:

    <script type="text/javascript">
    show=true;
    function toggle(){
    if (show){
    $('div.input').hide();
    }else{
    $('div.input').show();
    }
    show = !show
    }
    </script>
    <a href="javascript:toggle()" target="_self">toggle input</a>

    Johan

    _______________________________________________
    IPython-User mailing list
    ipy...@...org
    http://mail.scipy.org/mailman/listinfo/ipython-user

    --
    --raju
  • Raju Joseph at Nov 27, 2012 at 9:52 am
    This is going to be neat.
    Thanks as always Matthias and for correcting my assumption on the "raw
    input" front....

    Let me get my hands dirty on this.

    On Tue, Nov 27, 2012 at 3:02 PM, Matthias BUSSONNIER wrote:


    Le 27 nov. 2012 à 09:06, Raju Joseph a écrit :
    Thanks a lot Johan. This is going to be most helpful.

    **NOOB question alert**
    Is there any way in which a markdown cell could be used to create an
    input form to accept variables/parameters?
    These variable values could then be used to pipe into the code in the
    IPython input cells.

    Yes it is,
    Markdown support html and javascript <script> tag.

    just write your form and bind `submit` (or anything else) to a function
    that call
    IPython.notebook.kernel.execute('stringofcode',callbackfunction);

    This along with "toggle input" would be very useful in building
    quick-fix applications or application prototypes. (especially custom
    reporting applications)
    Such a notebook created could then be safely shared with business teams
    (aka teams who go glassy eyed on seeing code that need to be meddled with)

    Toggle input has already been discussed, we want to do it but
    * need to find the correct UI.
    * There was some issues with CodeMirror Library in hiding code cell.
    I believe raw input is currently not handled by IPython, hence not sure
    if that would prevent the creation of such a form.

    Raw input prevent **python** from asking the user to type.
    As long as you know that the user will have to enter something you could
    ask JS to pop up a dialog.
    This just is not be possible **while** python code are executed.
    Seeking forgiveness in advance if the question was a stupid one.
    That was not a stupid question, and questions are never stupid,
    The answer is just more obvious to people in the field.

    --
    Matthias
    Many Thanks,
    Raju


    On Tue, Nov 27, 2012 at 12:25 AM, Johan Beke wrote:
    Putting the following code in a markdown cell works fine for me:

    <script type="text/javascript">
    show=true;
    function toggle(){
    if (show){
    $('div.input').hide();
    }else{
    $('div.input').show();
    }
    show = !show
    }
    </script>
    <a href="javascript:toggle()" target="_self">toggle input</a>

    Johan

    _______________________________________________
    IPython-User mailing list
    ipy...@...org
    http://mail.scipy.org/mailman/listinfo/ipython-user


    --
    --raju
    _______________________________________________
    IPython-User mailing list
    ipy...@...org
    http://mail.scipy.org/mailman/listinfo/ipython-user
    _______________________________________________
    IPython-User mailing list
    ipy...@...org
    http://mail.scipy.org/mailman/listinfo/ipython-user


    --
    --raju

Related Discussions

Discussion Navigation
viewthread | post

2 users in discussion

Raju Joseph: 2 posts Johan Beke: 1 post