[IPython-User] Hide code cells in the notebook

Matthias BUSSONNIER bussonniermatthias@gmail....
Tue Nov 27 03:32:36 CST 2012


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 <johanbeke@hotmail.com> 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
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
> 
> 
> -- 
> --raju
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user



More information about the IPython-User mailing list