NotebookTools.py 759 Bytes
Newer Older
Nick Sauerwein's avatar
Nick Sauerwein committed
1
from IPython.display import display_html
2 3

def hide():
Nick Sauerwein's avatar
Nick Sauerwein committed
4 5

    display_html('''<script>
6 7 8 9 10 11 12 13 14 15 16
    code_show=false; 
    function code_toggle() {
     if (code_show){
     $('div.input').hide();
     } else {
     $('div.input').show();
     }
     code_show = !code_show
    } 
    $( document ).ready(code_toggle);
    </script>
Nick Sauerwein's avatar
Nick Sauerwein committed
17 18 19 20 21 22 23 24 25 26
    <h1><a href="javascript:code_toggle()">Hide Code</a></h1>''')
    
def open_tab(url):
    print (url)
    display_html("<script type='text/javascript'>window.open('"+url+"', '_blank');</script>", raw = True)
    
def open_window(url, width = 800, height = 500):
    print (url)
    display_html("<script type='text/javascript'>window.open('"+url+"', '_blank','width="+str(width)+", height="+str(height)+"');</script>", raw = True)