diff --git a/IPython/frontend/html/notebook/widgets/__init__.py b/IPython/frontend/html/notebook/widgets/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/IPython/frontend/html/notebook/widgets/__init__.py +++ /dev/null diff --git a/docs/examples/widgets/directview/directview.ipynb b/docs/examples/widgets/directview/directview.ipynb new file mode 100644 index 0000000..e4145f4 --- /dev/null +++ b/docs/examples/widgets/directview/directview.ipynb @@ -0,0 +1,20 @@ +{ + "metadata": { + "name": "directview" + }, + "nbformat": 3, + "worksheets": [ + { + "cells": [ + { + "cell_type": "code", + "input": [ + "" + ], + "language": "python", + "outputs": [] + } + ] + } + ] +} \ No newline at end of file diff --git a/IPython/frontend/html/notebook/widgets/directview.js b/docs/examples/widgets/directview/directview.js similarity index 100% rename from IPython/frontend/html/notebook/widgets/directview.js rename to docs/examples/widgets/directview/directview.js diff --git a/IPython/frontend/html/notebook/widgets/directview.py b/docs/examples/widgets/directview/directview.py similarity index 93% rename from IPython/frontend/html/notebook/widgets/directview.py rename to docs/examples/widgets/directview/directview.py index 8a46c63..59fa0fb 100644 --- a/IPython/frontend/html/notebook/widgets/directview.py +++ b/docs/examples/widgets/directview/directview.py @@ -31,7 +31,7 @@ from IPython.core.displaypub import publish_pretty import os, sys from IPython.core.display import Javascript -from .widget import JavascriptWidget +from widget import JavascriptWidget class DirectViewWidget(JavascriptWidget): @@ -42,7 +42,9 @@ class DirectViewWidget(JavascriptWidget): super(DirectViewWidget,self).__init__() def render(self): - jscode = self.load_file(u'directview.js') + fname = os.path.join(os.path.dirname(__file__), u'directview.js') + with open(fname, 'r') as f: + jscode = f.read() data = { 'widget_var': self.widget_var, 'targets' : self.encode_json(self.targets) diff --git a/IPython/frontend/html/notebook/widgets/widget.py b/docs/examples/widgets/directview/widget.py similarity index 87% rename from IPython/frontend/html/notebook/widgets/widget.py rename to docs/examples/widgets/directview/widget.py index d8fed29..a209913 100644 --- a/IPython/frontend/html/notebook/widgets/widget.py +++ b/docs/examples/widgets/directview/widget.py @@ -39,19 +39,6 @@ class JavascriptWidget(object): ns = get_ipython().user_ns ns[self.widget_var] = self - def load_file(self, fname): - """Read a file in the same directory as this module. - - This exists to make it easy for developers of widget to put Javascript - source files and templates in the same directory as their Python - widget code. This is much better than writing the JavaScript code in - Python strings. - """ - fname = os.path.join(os.path.dirname(__file__), fname) - with open(fname) as f: - data = f.read() - return data - def encode_json(self, o): return jsonapi.dumps(o)