Skip to content

Commit

Permalink
Don't try to support IPython 2.x
Browse files Browse the repository at this point in the history
It's already broken, and has been for some time.
  • Loading branch information
takluyver committed Oct 22, 2014
1 parent ee7c063 commit bd0d132
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 36 deletions.
8 changes: 3 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ This is a Turtle module for the IPython notebook. It's based on code by
as a class assignment (the other was `PACattack <http://macewancmpt395.github.io/PACattack/>`_;
I could have based this on either, but I had to pick one).

To use it, first run this (you can skip this on IPython 3 or above)::
Mobilechelonian requires IPython 3 or above.

from mobilechelonian import prepare_js
prepare_js()

Then create a turtle and draw::
Using it looks like this::

from mobilechelonian import Turtle
t = Turtle()
t.speed(5)
colours=["red","blue","yellow","brown","black","purple","green"]

t.penup(); t.left(90); t.forward(200);t.right(90);t.pendown()
for i in range (0,18):
t.pencolor(colours[i%7])
Expand Down
20 changes: 3 additions & 17 deletions Test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,13 @@
"name": "python3"
},
"name": "",
"signature": "sha256:6986cc358be838072e377a7a9d1d7e74b0dcd7d9ddfbb19bdbc33bf8e8125e94"
"signature": "sha256:91c2a08fe2a3a6fe5c5fade1a8497ad53afd46ec5d686e84b5cee6eb9f0e8bd4"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"from mobilechelonian import prepare_js\n",
"prepare_js()"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
Expand All @@ -48,8 +36,7 @@
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
"outputs": []
},
{
"cell_type": "code",
Expand All @@ -59,8 +46,7 @@
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 3
"outputs": []
}
],
"metadata": {}
Expand Down
15 changes: 1 addition & 14 deletions mobilechelonian/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,12 @@

from IPython.html import widgets, nbextensions
from IPython.utils.traitlets import Unicode, List
from IPython.display import display, Javascript
from IPython.display import display

def install_js():
pkgdir = os.path.dirname(__file__)
nbextensions.install_nbextension([os.path.join(pkgdir, 'mobilechelonianjs')], symlink=True)

def prepare_js():
"""Prepare Javascript - needed on IPython 2.x before using Turtle.
This is unnecessary on IPython 3 or above.
"""
install_js()
display(Javascript("""require(['nbextensions/mobilechelonianjs/turtlewidget.js',
'widgets/js/manager'],
function(turtlemod, manager) {
manager.WidgetManager.register_widget_view(
'TurtleView', turtlemod.TurtleView);
}, function(err) {console.log(err);});"""))

class Turtle(widgets.DOMWidget):
_view_module = Unicode("nbextensions/mobilechelonianjs/turtlewidget", sync=True)
_view_name = Unicode('TurtleView', sync=True)
Expand Down

0 comments on commit bd0d132

Please sign in to comment.