{ "metadata": { "name": "", "signature": "sha256:a975d23c21fff1d9dded2722e1f502b3324387b6ad66c745606db29db3f8078c" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "%%HTML\n", "
\n", "" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "
\n", "" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] } ], "prompt_number": 44 }, { "cell_type": "code", "collapsed": false, "input": [ "# iframe_with_source wraps HTML+javascript into an iframe, to avoid DOM and javascript conflicts\n", "\n", "from IPython.display import HTML\n", "import json\n", "\n", "def iframe_with_source(source, height='200px'):\n", " name = 'iframe-%d' % get_ipython().execution_count\n", " source = json.dumps(source).replace('\n", "\n", "\"\"\"\n", " # Fill in the %s slots with id, width, height, and the HTML source\n", " return HTML(template % (name, height, name, source))" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 58 }, { "cell_type": "code", "collapsed": false, "input": [ "# Talk to kernel from inside iframe\n", "\n", "source = \"\"\"\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\n", "\"\"\"\n", "\n", "iframe_with_source(source, height='100px')" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", "\n", "\n" ], "metadata": {}, "output_type": "pyout", "prompt_number": 59, "text": [ "" ] } ], "prompt_number": 59 }, { "cell_type": "code", "collapsed": false, "input": [ "hithere" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 39, "text": [ "99" ] } ], "prompt_number": 39 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }