Show More
@@ -14,7 +14,8 b'' | |||
|
14 | 14 | // as injecting require.js make marked not to put itself in the globals, |
|
15 | 15 | // which make both this file fail at setting marked configuration, and textcell.js |
|
16 | 16 | // which search marked into global. |
|
17 |
require(['components/marked/lib/marked' |
|
|
17 | require(['components/marked/lib/marked', | |
|
18 | 'notebook/js/widgets/basic_widgets'], | |
|
18 | 19 | |
|
19 | 20 | function (marked) { |
|
20 | 21 |
@@ -1295,11 +1295,13 b' var IPython = (function (IPython) {' | |||
|
1295 | 1295 | |
|
1296 | 1296 | |
|
1297 | 1297 | /** |
|
1298 | * Once a session is started, link the code cells to the kernel | |
|
1298 | * Once a session is started, link the code cells to the kernel and pass the | |
|
1299 | * comm manager to the widget manager | |
|
1299 | 1300 | * |
|
1300 | 1301 | */ |
|
1301 | 1302 | Notebook.prototype._session_started = function(){ |
|
1302 | 1303 | this.kernel = this.session.kernel; |
|
1304 | IPython.widget_manager.attach_comm_manager(this.kernel.comm_manager); | |
|
1303 | 1305 | var ncells = this.ncells(); |
|
1304 | 1306 | for (var i=0; i<ncells; i++) { |
|
1305 | 1307 | var cell = this.get_cell(i); |
This diff has been collapsed as it changes many lines, (786 lines changed) Show them Hide them | |||
@@ -24,445 +24,453 b' define(["components/underscore/underscore-min",' | |||
|
24 | 24 | "components/backbone/backbone-min", |
|
25 | 25 | ], function(){ |
|
26 | 26 | |
|
27 | // Only run once on a notebook. | |
|
28 | if (IPython.notebook.widget_manager == undefined) { | |
|
29 | ||
|
30 |
|
|
|
31 | // WidgetModel class | |
|
32 | //-------------------------------------------------------------------- | |
|
33 | var WidgetModel = Backbone.Model.extend({ | |
|
34 | constructor: function(comm_manager, comm, widget_view_types) { | |
|
35 | this.comm_manager = comm_manager; | |
|
36 | this.widget_view_types = widget_view_types; | |
|
37 |
|
|
|
38 |
|
|
|
39 | this.msg_buffer = null; | |
|
40 | this.views = {}; | |
|
41 | ||
|
42 | // Remember comm associated with the model. | |
|
43 | this.comm = comm; | |
|
44 | comm.model = this; | |
|
45 | ||
|
46 | // Hook comm messages up to model. | |
|
47 | comm.on_close($.proxy(this.handle_comm_closed, this)); | |
|
48 | comm.on_msg($.proxy(this.handle_comm_msg, this)); | |
|
49 | ||
|
50 | return Backbone.Model.apply(this); | |
|
51 | }, | |
|
52 | ||
|
53 | ||
|
54 | update_other_views: function(caller) { | |
|
55 | this.last_modified_view = caller; | |
|
56 | this.save(this.changedAttributes(), {patch: true}); | |
|
57 | ||
|
58 |
for (var |
|
|
59 |
var view |
|
|
60 |
f |
|
|
61 |
|
|
|
62 | if (view !== caller) { | |
|
63 | view.update(); | |
|
64 | } | |
|
27 | ||
|
28 | //-------------------------------------------------------------------- | |
|
29 | // WidgetModel class | |
|
30 | //-------------------------------------------------------------------- | |
|
31 | var WidgetModel = Backbone.Model.extend({ | |
|
32 | constructor: function(comm_manager, comm, widget_view_types) { | |
|
33 | this.comm_manager = comm_manager; | |
|
34 | this.widget_view_types = widget_view_types; | |
|
35 | this.pending_msgs = 0; | |
|
36 | this.msg_throttle = 3; | |
|
37 | this.msg_buffer = null; | |
|
38 | this.views = {}; | |
|
39 | ||
|
40 | // Remember comm associated with the model. | |
|
41 | this.comm = comm; | |
|
42 | comm.model = this; | |
|
43 | ||
|
44 | // Hook comm messages up to model. | |
|
45 | comm.on_close($.proxy(this.handle_comm_closed, this)); | |
|
46 | comm.on_msg($.proxy(this.handle_comm_msg, this)); | |
|
47 | ||
|
48 | return Backbone.Model.apply(this); | |
|
49 | }, | |
|
50 | ||
|
51 | ||
|
52 | update_other_views: function(caller) { | |
|
53 | this.last_modified_view = caller; | |
|
54 | this.save(this.changedAttributes(), {patch: true}); | |
|
55 | ||
|
56 | for (var output_area in this.views) { | |
|
57 | var views = this.views[output_area]; | |
|
58 | for (var view_index in views) { | |
|
59 | var view = views[view_index]; | |
|
60 | if (view !== caller) { | |
|
61 | view.update(); | |
|
65 | 62 | } |
|
66 | 63 | } |
|
67 |
} |
|
|
68 | ||
|
69 | ||
|
70 | handle_status: function (output_area, msg) { | |
|
71 | //execution_state : ('busy', 'idle', 'starting') | |
|
72 | if (msg.content.execution_state=='idle') { | |
|
73 | ||
|
74 | // Send buffer if this message caused another message to be | |
|
75 | // throttled. | |
|
76 | if (this.msg_buffer != null) { | |
|
77 | if (this.msg_throttle == this.pending_msgs && | |
|
78 | this.msg_buffer.length > 0) { | |
|
79 | ||
|
80 | var output_area = this._get_msg_output_area(msg); | |
|
81 | var callbacks = this._make_callbacks(output_area); | |
|
82 | var data = {sync_method: 'update', sync_data: this.msg_buffer}; | |
|
83 | comm.send(data, callbacks); | |
|
84 | this.msg_buffer = null; | |
|
85 | } else { | |
|
64 | } | |
|
65 | }, | |
|
86 | 66 | |
|
87 | // Only decrease the pending message count if the buffer | |
|
88 | // doesn't get flushed (sent). | |
|
89 | --this.pending_msgs; | |
|
90 | } | |
|
91 |
|
|
|
67 | ||
|
68 | handle_status: function (output_area, msg) { | |
|
69 | //execution_state : ('busy', 'idle', 'starting') | |
|
70 | if (msg.content.execution_state=='idle') { | |
|
71 | ||
|
72 | // Send buffer if this message caused another message to be | |
|
73 | // throttled. | |
|
74 | if (this.msg_buffer != null && | |
|
75 | this.msg_throttle == this.pending_msgs && | |
|
76 | this.msg_buffer.length > 0) { | |
|
77 | ||
|
78 | var output_area = this._get_msg_output_area(msg); | |
|
79 | var callbacks = this._make_callbacks(output_area); | |
|
80 | var data = {sync_method: 'update', sync_data: this.msg_buffer}; | |
|
81 | comm.send(data, callbacks); | |
|
82 | this.msg_buffer = null; | |
|
83 | } else { | |
|
84 | ||
|
85 | // Only decrease the pending message count if the buffer | |
|
86 | // doesn't get flushed (sent). | |
|
87 | --this.pending_msgs; | |
|
92 | 88 | } |
|
93 |
} |
|
|
94 | ||
|
95 | ||
|
96 | // Custom syncronization logic. | |
|
97 | handle_sync: function (method, options) { | |
|
98 | var model_json = this.toJSON(); | |
|
99 | ||
|
100 | // Only send updated state if the state hasn't been changed | |
|
101 | // during an update. | |
|
102 | if (!this.updating) { | |
|
103 | if (this.pending_msgs >= this.msg_throttle) { | |
|
104 | // The throttle has been exceeded, buffer the current msg so | |
|
105 | // it can be sent once the kernel has finished processing | |
|
106 | // some of the existing messages. | |
|
107 | if (method=='patch') { | |
|
108 |
|
|
|
109 |
|
|
|
110 | } | |
|
111 | for (var attr in options.attrs) { | |
|
112 | this.msg_buffer[attr] = options.attrs[attr]; | |
|
113 | } | |
|
114 | } else { | |
|
89 | } | |
|
90 | }, | |
|
91 | ||
|
92 | ||
|
93 | // Custom syncronization logic. | |
|
94 | handle_sync: function (method, options) { | |
|
95 | var model_json = this.toJSON(); | |
|
96 | ||
|
97 | // Only send updated state if the state hasn't been changed | |
|
98 | // during an update. | |
|
99 | if (!this.updating) { | |
|
100 | if (this.pending_msgs >= this.msg_throttle) { | |
|
101 | // The throttle has been exceeded, buffer the current msg so | |
|
102 | // it can be sent once the kernel has finished processing | |
|
103 | // some of the existing messages. | |
|
104 | if (method=='patch') { | |
|
105 | if (this.msg_buffer == null) { | |
|
115 | 106 | this.msg_buffer = $.extend({}, model_json); // Copy |
|
116 | 107 | } |
|
117 | ||
|
118 | } else { | |
|
119 | // We haven't exceeded the throttle, send the message like | |
|
120 | // normal. If this is a patch operation, just send the | |
|
121 | // changes. | |
|
122 | var send_json = model_json; | |
|
123 | if (method=='patch') { | |
|
124 | send_json = {}; | |
|
125 | for (var attr in options.attrs) { | |
|
126 | send_json[attr] = options.attrs[attr]; | |
|
127 | } | |
|
108 | for (var attr in options.attrs) { | |
|
109 | this.msg_buffer[attr] = options.attrs[attr]; | |
|
128 | 110 | } |
|
111 | } else { | |
|
112 | this.msg_buffer = $.extend({}, model_json); // Copy | |
|
113 | } | |
|
129 | 114 | |
|
130 | var data = {sync_method: method, sync_data: send_json}; | |
|
131 | var output_area = this.last_modified_view.output_area; | |
|
132 | var callbacks = this._make_callbacks(output_area); | |
|
133 | this.comm.send(data, callbacks); | |
|
134 |
|
|
|
115 | } else { | |
|
116 | // We haven't exceeded the throttle, send the message like | |
|
117 | // normal. If this is a patch operation, just send the | |
|
118 | // changes. | |
|
119 | var send_json = model_json; | |
|
120 | if (method=='patch') { | |
|
121 | send_json = {}; | |
|
122 | for (var attr in options.attrs) { | |
|
123 | send_json[attr] = options.attrs[attr]; | |
|
124 | } | |
|
135 | 125 | } |
|
126 | ||
|
127 | var data = {sync_method: method, sync_data: send_json}; | |
|
128 | var output_area = this.last_modified_view.output_area; | |
|
129 | var callbacks = this._make_callbacks(output_area); | |
|
130 | this.comm.send(data, callbacks); | |
|
131 | this.pending_msgs++; | |
|
136 | 132 | } |
|
137 |
|
|
|
138 | // Since the comm is a one-way communication, assume the message | |
|
139 | // arrived. | |
|
140 | return model_json; | |
|
141 | }, | |
|
142 | ||
|
143 | ||
|
144 | // Handle incomming comm msg. | |
|
145 | handle_comm_msg: function (msg) { | |
|
146 | var method = msg.content.data.method; | |
|
147 | switch (method){ | |
|
148 | case 'display': | |
|
149 | ||
|
150 | // Try to get the cell index. | |
|
151 | var output_area = this._get_output_area(msg.parent_header.msg_id); | |
|
152 | if (output_area == null) { | |
|
153 | console.log("Could not determine where the display" + | |
|
154 | " message was from. Widget will not be displayed") | |
|
133 | } | |
|
134 | ||
|
135 | // Since the comm is a one-way communication, assume the message | |
|
136 | // arrived. | |
|
137 | return model_json; | |
|
138 | }, | |
|
139 | ||
|
140 | ||
|
141 | // Handle incomming comm msg. | |
|
142 | handle_comm_msg: function (msg) { | |
|
143 | var method = msg.content.data.method; | |
|
144 | switch (method){ | |
|
145 | case 'display': | |
|
146 | ||
|
147 | // Try to get the cell index. | |
|
148 | var output_area = this._get_output_area(msg.parent_header.msg_id); | |
|
149 | if (output_area == null) { | |
|
150 | console.log("Could not determine where the display" + | |
|
151 | " message was from. Widget will not be displayed") | |
|
152 | } else { | |
|
153 | this.display_view(msg.content.data.view_name, | |
|
154 | msg.content.data.parent, | |
|
155 | output_area); | |
|
156 | } | |
|
157 | break; | |
|
158 | case 'update': | |
|
159 | this.handle_update(msg.content.data.state); | |
|
160 | break; | |
|
161 | } | |
|
162 | }, | |
|
163 | ||
|
164 | ||
|
165 | // Handle when a widget is updated via the python side. | |
|
166 | handle_update: function (state) { | |
|
167 | this.updating = true; | |
|
168 | try { | |
|
169 | for (var key in state) { | |
|
170 | if (state.hasOwnProperty(key)) { | |
|
171 | if (key == "_css"){ | |
|
172 | this.css = state[key]; | |
|
155 | 173 | } else { |
|
156 |
this. |
|
|
157 | msg.content.data.parent, | |
|
158 | output_area); | |
|
159 | } | |
|
160 | break; | |
|
161 | case 'update': | |
|
162 | this.handle_update(msg.content.data.state); | |
|
163 | break; | |
|
164 | } | |
|
165 | }, | |
|
166 | ||
|
167 | ||
|
168 | // Handle when a widget is updated via the python side. | |
|
169 | handle_update: function (state) { | |
|
170 | this.updating = true; | |
|
171 | try { | |
|
172 | for (var key in state) { | |
|
173 | if (state.hasOwnProperty(key)) { | |
|
174 | if (key == "_css"){ | |
|
175 | this.css = state[key]; | |
|
176 | } else { | |
|
177 | this.set(key, state[key]); | |
|
178 | } | |
|
174 | this.set(key, state[key]); | |
|
179 | 175 | } |
|
180 | 176 | } |
|
181 | this.id = this.comm.comm_id; | |
|
182 | this.save(); | |
|
183 | } finally { | |
|
184 | this.updating = false; | |
|
185 | 177 | } |
|
186 | }, | |
|
187 | ||
|
188 | ||
|
189 | // Handle when a widget is closed. | |
|
190 | handle_comm_closed: function (msg) { | |
|
191 | for (var output_area in this.views) { | |
|
192 | var views = this.views[output_area]; | |
|
193 | for (var view_index in views) { | |
|
194 | var view = views[view_index]; | |
|
195 | view.remove(); | |
|
196 | } | |
|
178 | this.id = this.comm.comm_id; | |
|
179 | this.save(); | |
|
180 | } finally { | |
|
181 | this.updating = false; | |
|
182 | } | |
|
183 | }, | |
|
184 | ||
|
185 | ||
|
186 | // Handle when a widget is closed. | |
|
187 | handle_comm_closed: function (msg) { | |
|
188 | for (var output_area in this.views) { | |
|
189 | var views = this.views[output_area]; | |
|
190 | for (var view_index in views) { | |
|
191 | var view = views[view_index]; | |
|
192 | view.remove(); | |
|
197 | 193 | } |
|
198 |
} |
|
|
199 | ||
|
200 | ||
|
201 | // Create view that represents the model. | |
|
202 | display_view: function (view_name, parent_comm_id, output_area) { | |
|
203 | var new_views = []; | |
|
204 | ||
|
205 | var displayed = false; | |
|
206 | if (parent_comm_id != undefined) { | |
|
207 | var parent_comm = this.comm_manager.comms[parent_comm_id]; | |
|
208 |
|
|
|
209 |
|
|
|
210 |
|
|
|
211 | var parent_view = parent_views[parent_view_index]; | |
|
212 | if (parent_view.display_child != undefined) { | |
|
213 | var view = this._create_view(view_name, output_area); | |
|
214 |
|
|
|
215 |
|
|
|
216 |
|
|
|
217 |
|
|
|
194 | } | |
|
195 | }, | |
|
196 | ||
|
197 | ||
|
198 | // Create view that represents the model. | |
|
199 | display_view: function (view_name, parent_comm_id, output_area) { | |
|
200 | var new_views = []; | |
|
201 | ||
|
202 | var displayed = false; | |
|
203 | if (parent_comm_id != undefined) { | |
|
204 | var parent_comm = this.comm_manager.comms[parent_comm_id]; | |
|
205 | var parent_model = parent_comm.model; | |
|
206 | var parent_views = parent_model.views[output_area]; | |
|
207 | for (var parent_view_index in parent_views) { | |
|
208 | var parent_view = parent_views[parent_view_index]; | |
|
209 | if (parent_view.display_child != undefined) { | |
|
210 | var view = this._create_view(view_name, output_area); | |
|
211 | new_views.push(view); | |
|
212 | parent_view.display_child(view); | |
|
213 | displayed = true; | |
|
218 | 214 | } |
|
219 | 215 | } |
|
220 | ||
|
221 | if (!displayed) { | |
|
222 | // No parent view is defined or exists. Add the view's | |
|
223 | // element to cell's widget div. | |
|
224 | var view = this._create_view(view_name, output_area); | |
|
225 | new_views.push(view); | |
|
226 | this._get_widget_area_element(output_area, true) | |
|
227 | .append(view.$el); | |
|
228 | ||
|
216 | } | |
|
217 | ||
|
218 | if (!displayed) { | |
|
219 | // No parent view is defined or exists. Add the view's | |
|
220 | // element to cell's widget div. | |
|
221 | var view = this._create_view(view_name, output_area); | |
|
222 | new_views.push(view); | |
|
223 | this._get_widget_area_element(output_area, true) | |
|
224 | .append(view.$el); | |
|
225 | ||
|
226 | } | |
|
227 | ||
|
228 | for (var view_index in new_views) { | |
|
229 | var view = new_views[view_index]; | |
|
230 | view.update(); | |
|
231 | } | |
|
232 | }, | |
|
233 | ||
|
234 | ||
|
235 | // Create a view | |
|
236 | _create_view: function (view_name, output_area) { | |
|
237 | var view = new this.widget_view_types[view_name]({model: this}); | |
|
238 | view.render(); | |
|
239 | if (this.views[output_area]==undefined) { | |
|
240 | this.views[output_area] = [] | |
|
241 | } | |
|
242 | this.views[output_area].push(view); | |
|
243 | view.output_area = output_area; | |
|
244 | ||
|
245 | // Handle when the view element is remove from the page. | |
|
246 | var that = this; | |
|
247 | view.$el.on("remove", function(){ | |
|
248 | var index = that.views[output_area].indexOf(view); | |
|
249 | if (index > -1) { | |
|
250 | that.views[output_area].splice(index, 1); | |
|
229 | 251 | } |
|
230 | ||
|
231 | for (var view_index in new_views) { | |
|
232 | var view = new_views[view_index]; | |
|
233 | view.update(); | |
|
252 | view.remove(); // Clean-up view | |
|
253 | if (that.views[output_area].length()==0) { | |
|
254 | delete that.views[output_area]; | |
|
234 | 255 | } |
|
235 | }, | |
|
236 | ||
|
237 | 256 | |
|
238 | // Create a view | |
|
239 | _create_view: function (view_name, output_area) { | |
|
240 | var view = new this.widget_view_types[view_name]({model: this}); | |
|
241 | view.render(); | |
|
242 | if (this.views[output_area]==undefined) { | |
|
243 | this.views[output_area] = [] | |
|
257 | // Close the comm if there are no views left. | |
|
258 | if (that.views.length()==0) { | |
|
259 | that.comm.close(); | |
|
244 | 260 | } |
|
245 | this.views[output_area].push(view); | |
|
246 | view.output_area = output_area; | |
|
247 | ||
|
248 | // Handle when the view element is remove from the page. | |
|
249 | var that = this; | |
|
250 | view.$el.on("remove", function(){ | |
|
251 | var index = that.views[output_area].indexOf(view); | |
|
252 | if (index > -1) { | |
|
253 | that.views[output_area].splice(index, 1); | |
|
254 | } | |
|
255 | view.remove(); // Clean-up view | |
|
256 | if (that.views[output_area].length()==0) { | |
|
257 | delete that.views[output_area]; | |
|
258 | } | |
|
259 | ||
|
260 | // Close the comm if there are no views left. | |
|
261 | if (that.views.length()==0) { | |
|
262 | that.comm.close(); | |
|
263 | } | |
|
264 | }); | |
|
265 | return view; | |
|
266 | }, | |
|
261 | }); | |
|
262 | return view; | |
|
263 | }, | |
|
267 | 264 | |
|
268 | 265 | |
|
269 |
|
|
|
270 |
|
|
|
271 |
|
|
|
272 |
|
|
|
273 |
|
|
|
274 |
|
|
|
275 |
|
|
|
276 |
|
|
|
277 |
|
|
|
278 |
|
|
|
279 |
|
|
|
280 | }, | |
|
281 | get_output_area : function() { | |
|
282 | if (that.last_modified_view != undefined && | |
|
283 | that.last_modified_view.output_area != undefined) { | |
|
284 | return that.last_modified_view.output_area; | |
|
285 | } else { | |
|
286 | return null | |
|
287 | } | |
|
288 | }, | |
|
266 | // Build a callback dict. | |
|
267 | _make_callbacks: function (output_area) { | |
|
268 | var callbacks = {}; | |
|
269 | if (output_area != null) { | |
|
270 | var that = this; | |
|
271 | callbacks = { | |
|
272 | iopub : { | |
|
273 | output : $.proxy(output_area.handle_output, output_area), | |
|
274 | clear_output : $.proxy(output_area.handle_clear_output, output_area), | |
|
275 | status : function(msg){ | |
|
276 | that.handle_status(output_area, msg); | |
|
289 | 277 | }, |
|
290 | }; | |
|
291 | } | |
|
292 | return callbacks; | |
|
293 | }, | |
|
278 | get_output_area : function() { | |
|
279 | if (that.last_modified_view != undefined && | |
|
280 | that.last_modified_view.output_area != undefined) { | |
|
281 | return that.last_modified_view.output_area; | |
|
282 | } else { | |
|
283 | return null | |
|
284 | } | |
|
285 | }, | |
|
286 | }, | |
|
287 | }; | |
|
288 | } | |
|
289 | return callbacks; | |
|
290 | }, | |
|
294 | 291 | |
|
295 | 292 | |
|
296 |
|
|
|
297 |
|
|
|
298 |
|
|
|
299 |
|
|
|
300 |
|
|
|
301 |
|
|
|
302 |
|
|
|
303 |
|
|
|
304 |
|
|
|
305 |
|
|
|
306 | } | |
|
293 | // Get the output area corresponding to the msg_id. | |
|
294 | // output_area is an instance of Ipython.OutputArea | |
|
295 | _get_output_area: function (msg_id) { | |
|
296 | ||
|
297 | // First, guess cell.execute triggered | |
|
298 | var cells = IPython.notebook.get_cells(); | |
|
299 | for (var cell_index in cells) { | |
|
300 | if (cells[cell_index].last_msg_id == msg_id) { | |
|
301 | var cell = IPython.notebook.get_cell(cell_index) | |
|
302 | return cell.output_area; | |
|
307 | 303 | } |
|
304 | } | |
|
308 | 305 | |
|
309 |
|
|
|
310 |
|
|
|
311 |
|
|
|
312 |
|
|
|
313 |
|
|
|
314 |
|
|
|
315 | } | |
|
306 | // Second, guess widget triggered | |
|
307 | var callbacks = this.comm_manager.kernel.get_callbacks_for_msg(msg_id) | |
|
308 | if (callbacks != undefined && callbacks.iopub != undefined && callbacks.iopub.get_output_area != undefined) { | |
|
309 | var output_area = callbacks.iopub.get_output_area(); | |
|
310 | if (output_area != null) { | |
|
311 | return output_area; | |
|
316 | 312 | } |
|
317 |
|
|
|
318 | // Not triggered by a widget or a cell | |
|
319 | return null; | |
|
320 | }, | |
|
321 | ||
|
322 | // Gets widget output area (as a JQuery element) from the | |
|
323 | // output_area (Ipython.OutputArea instance) | |
|
324 | _get_widget_area_element: function (output_area, show) { | |
|
325 | var widget_area = output_area.element | |
|
326 | .parent() // output_wrapper | |
|
327 | .parent() // cell | |
|
328 | .find('.widget-area'); | |
|
329 | if (show) { widget_area.show(); } | |
|
330 | return widget_area.find('.widget-subarea'); | |
|
331 | }, | |
|
332 | ||
|
333 | }); | |
|
334 | ||
|
335 | ||
|
336 | //-------------------------------------------------------------------- | |
|
337 | // WidgetView class | |
|
338 | //-------------------------------------------------------------------- | |
|
339 | var WidgetView = Backbone.View.extend({ | |
|
340 | ||
|
341 | initialize: function() { | |
|
342 | this.visible = true; | |
|
343 | this.model.on('change',this.update,this); | |
|
344 | this._add_class_calls = this.model.get('_add_class')[0]; | |
|
345 | this._remove_class_calls = this.model.get('_remove_class')[0]; | |
|
346 | }, | |
|
313 | } | |
|
347 | 314 | |
|
348 | update: function() { | |
|
349 | if (this.model.get('visible') != undefined) { | |
|
350 | if (this.visible != this.model.get('visible')) { | |
|
351 | this.visible = this.model.get('visible'); | |
|
352 | if (this.visible) { | |
|
353 | this.$el.show(); | |
|
354 | } else { | |
|
355 | this.$el.hide(); | |
|
356 | } | |
|
315 | // Not triggered by a widget or a cell | |
|
316 | return null; | |
|
317 | }, | |
|
318 | ||
|
319 | // Gets widget output area (as a JQuery element) from the | |
|
320 | // output_area (Ipython.OutputArea instance) | |
|
321 | _get_widget_area_element: function (output_area, show) { | |
|
322 | var widget_area = output_area.element | |
|
323 | .parent() // output_wrapper | |
|
324 | .parent() // cell | |
|
325 | .find('.widget-area'); | |
|
326 | if (show) { widget_area.show(); } | |
|
327 | return widget_area.find('.widget-subarea'); | |
|
328 | }, | |
|
329 | ||
|
330 | }); | |
|
331 | ||
|
332 | ||
|
333 | //-------------------------------------------------------------------- | |
|
334 | // WidgetView class | |
|
335 | //-------------------------------------------------------------------- | |
|
336 | var WidgetView = Backbone.View.extend({ | |
|
337 | ||
|
338 | initialize: function() { | |
|
339 | this.visible = true; | |
|
340 | this.model.on('change',this.update,this); | |
|
341 | this._add_class_calls = this.model.get('_add_class')[0]; | |
|
342 | this._remove_class_calls = this.model.get('_remove_class')[0]; | |
|
343 | }, | |
|
344 | ||
|
345 | update: function() { | |
|
346 | if (this.model.get('visible') != undefined) { | |
|
347 | if (this.visible != this.model.get('visible')) { | |
|
348 | this.visible = this.model.get('visible'); | |
|
349 | if (this.visible) { | |
|
350 | this.$el.show(); | |
|
351 | } else { | |
|
352 | this.$el.hide(); | |
|
357 | 353 | } |
|
358 | 354 | } |
|
359 | ||
|
360 | if (this.model.css != undefined) { | |
|
361 |
|
|
|
362 |
|
|
|
363 | ||
|
364 | // Apply the css traits to all elements that match the selector. | |
|
365 |
|
|
|
366 |
|
|
|
367 | var css_traits = this.model.css[selector]; | |
|
368 |
|
|
|
369 |
|
|
|
370 |
|
|
|
371 |
|
|
|
355 | } | |
|
356 | ||
|
357 | if (this.model.css != undefined) { | |
|
358 | for (var selector in this.model.css) { | |
|
359 | if (this.model.css.hasOwnProperty(selector)) { | |
|
360 | ||
|
361 | // Apply the css traits to all elements that match the selector. | |
|
362 | var elements = this.get_selector_element(selector); | |
|
363 | if (elements.length > 0) { | |
|
364 | var css_traits = this.model.css[selector]; | |
|
365 | for (var css_key in css_traits) { | |
|
366 | if (css_traits.hasOwnProperty(css_key)) { | |
|
367 | elements.css(css_key, css_traits[css_key]); | |
|
372 | 368 | } |
|
373 | 369 | } |
|
374 | 370 | } |
|
375 | 371 | } |
|
376 | 372 | } |
|
377 | ||
|
378 | var add_class = this.model.get('_add_class'); | |
|
379 | if (add_class != undefined){ | |
|
380 | var add_class_calls = add_class[0]; | |
|
381 |
|
|
|
382 |
|
|
|
383 | var elements = this.get_selector_element(add_class[1]); | |
|
384 | if (elements.length > 0) { | |
|
385 |
|
|
|
386 | } | |
|
387 | } | |
|
388 | } | |
|
389 | ||
|
390 | var remove_class = this.model.get('_remove_class'); | |
|
391 | if (remove_class != undefined){ | |
|
392 | var remove_class_calls = remove_class[0]; | |
|
393 | if (remove_class_calls > this._remove_class_calls) { | |
|
394 | this._remove_class_calls = remove_class_calls; | |
|
395 | var elements = this.get_selector_element(remove_class[1]); | |
|
396 | if (elements.length > 0) { | |
|
397 | elements.removeClass(remove_class[2]); | |
|
398 | } | |
|
399 | } | |
|
400 | } | |
|
401 | }, | |
|
402 | ||
|
403 | get_selector_element: function(selector) { | |
|
404 | // Get the elements via the css selector. If the selector is | |
|
405 | // blank, apply the style to the $el_to_style element. If | |
|
406 | // the $el_to_style element is not defined, use apply the | |
|
407 | // style to the view's element. | |
|
408 | var elements = this.$el.find(selector); | |
|
409 | if (selector=='') { | |
|
410 | if (this.$el_to_style == undefined) { | |
|
411 | elements = this.$el; | |
|
412 | } else { | |
|
413 | elements = this.$el_to_style; | |
|
373 | } | |
|
374 | ||
|
375 | var add_class = this.model.get('_add_class'); | |
|
376 | if (add_class != undefined){ | |
|
377 | var add_class_calls = add_class[0]; | |
|
378 | if (add_class_calls > this._add_class_calls) { | |
|
379 | this._add_class_calls = add_class_calls; | |
|
380 | var elements = this.get_selector_element(add_class[1]); | |
|
381 | if (elements.length > 0) { | |
|
382 | elements.addClass(add_class[2]); | |
|
414 | 383 | } |
|
384 | } | |
|
385 | } | |
|
386 | ||
|
387 | var remove_class = this.model.get('_remove_class'); | |
|
388 | if (remove_class != undefined){ | |
|
389 | var remove_class_calls = remove_class[0]; | |
|
390 | if (remove_class_calls > this._remove_class_calls) { | |
|
391 | this._remove_class_calls = remove_class_calls; | |
|
392 | var elements = this.get_selector_element(remove_class[1]); | |
|
393 | if (elements.length > 0) { | |
|
394 | elements.removeClass(remove_class[2]); | |
|
395 | } | |
|
396 | } | |
|
397 | } | |
|
398 | }, | |
|
399 | ||
|
400 | get_selector_element: function(selector) { | |
|
401 | // Get the elements via the css selector. If the selector is | |
|
402 | // blank, apply the style to the $el_to_style element. If | |
|
403 | // the $el_to_style element is not defined, use apply the | |
|
404 | // style to the view's element. | |
|
405 | var elements = this.$el.find(selector); | |
|
406 | if (selector=='') { | |
|
407 | if (this.$el_to_style == undefined) { | |
|
408 | elements = this.$el; | |
|
409 | } else { | |
|
410 | elements = this.$el_to_style; | |
|
415 | 411 | } |
|
416 | return elements; | |
|
417 | }, | |
|
418 |
} |
|
|
419 | ||
|
420 | ||
|
421 | //-------------------------------------------------------------------- | |
|
422 | // WidgetManager class | |
|
423 | //-------------------------------------------------------------------- | |
|
424 | var WidgetManager = function(comm_manager){ | |
|
425 | this.comm_manager = comm_manager; | |
|
426 | this.widget_model_types = {}; | |
|
427 |
|
|
|
428 | ||
|
429 | var that = this; | |
|
430 | Backbone.sync = function(method, model, options, error) { | |
|
431 | var result = model.handle_sync(method, options); | |
|
432 | if (options.success) { | |
|
433 |
|
|
|
434 | } | |
|
435 |
} |
|
|
412 | } | |
|
413 | return elements; | |
|
414 | }, | |
|
415 | }); | |
|
416 | ||
|
417 | ||
|
418 | //-------------------------------------------------------------------- | |
|
419 | // WidgetManager class | |
|
420 | //-------------------------------------------------------------------- | |
|
421 | var WidgetManager = function(){ | |
|
422 | this.comm_manager = null; | |
|
423 | this.widget_model_types = {}; | |
|
424 | this.widget_view_types = {}; | |
|
425 | ||
|
426 | var that = this; | |
|
427 | Backbone.sync = function(method, model, options, error) { | |
|
428 | var result = model.handle_sync(method, options); | |
|
429 | if (options.success) { | |
|
430 | options.success(result); | |
|
431 | } | |
|
432 | }; | |
|
433 | } | |
|
434 | ||
|
435 | ||
|
436 | WidgetManager.prototype.attach_comm_manager = function (comm_manager) { | |
|
437 | this.comm_manager = comm_manager; | |
|
438 | ||
|
439 | // Register already register widget model types with the comm manager. | |
|
440 | for (var widget_model_name in this.widget_model_types) { | |
|
441 | this.comm_manager.register_target(widget_model_name, $.proxy(this.handle_com_open, this)); | |
|
436 | 442 | } |
|
443 | } | |
|
437 | 444 | |
|
438 | 445 | |
|
439 |
|
|
|
440 |
|
|
|
441 |
|
|
|
446 | WidgetManager.prototype.register_widget_model = function (widget_model_name, widget_model_type) { | |
|
447 | // Register the widget with the comm manager. Make sure to pass this object's context | |
|
448 | // in so `this` works in the call back. | |
|
449 | if (this.comm_manager!=null) { | |
|
442 | 450 | this.comm_manager.register_target(widget_model_name, $.proxy(this.handle_com_open, this)); |
|
443 | this.widget_model_types[widget_model_name] = widget_model_type; | |
|
444 | 451 | } |
|
452 | this.widget_model_types[widget_model_name] = widget_model_type; | |
|
453 | } | |
|
445 | 454 | |
|
446 | 455 | |
|
447 |
|
|
|
448 |
|
|
|
449 |
|
|
|
456 | WidgetManager.prototype.register_widget_view = function (widget_view_name, widget_view_type) { | |
|
457 | this.widget_view_types[widget_view_name] = widget_view_type; | |
|
458 | } | |
|
450 | 459 | |
|
451 | 460 | |
|
452 |
|
|
|
453 |
|
|
|
454 |
|
|
|
455 |
|
|
|
461 | WidgetManager.prototype.handle_com_open = function (comm, msg) { | |
|
462 | var widget_type_name = msg.content.target_name; | |
|
463 | var widget_model = new this.widget_model_types[widget_type_name](this.comm_manager, comm, this.widget_view_types); | |
|
464 | } | |
|
456 | 465 | |
|
457 | 466 | |
|
458 |
|
|
|
459 |
|
|
|
460 |
|
|
|
461 |
|
|
|
462 |
|
|
|
463 |
|
|
|
467 | //-------------------------------------------------------------------- | |
|
468 | // Init code | |
|
469 | //-------------------------------------------------------------------- | |
|
470 | IPython.WidgetManager = WidgetManager; | |
|
471 | IPython.WidgetModel = WidgetModel; | |
|
472 | IPython.WidgetView = WidgetView; | |
|
464 | 473 | |
|
465 |
|
|
|
474 | IPython.widget_manager = new WidgetManager(); | |
|
466 | 475 | |
|
467 | }; | |
|
468 | 476 | }); |
@@ -1,8 +1,8 b'' | |||
|
1 | 1 | |
|
2 |
|
|
|
2 | define(["notebook/js/widget"], function(){ | |
|
3 | 3 | |
|
4 | 4 | var BoolWidgetModel = IPython.WidgetModel.extend({}); |
|
5 |
IPython |
|
|
5 | IPython.widget_manager.register_widget_model('BoolWidgetModel', BoolWidgetModel); | |
|
6 | 6 | |
|
7 | 7 | var CheckboxView = IPython.WidgetView.extend({ |
|
8 | 8 | |
@@ -51,7 +51,7 b' require(["notebook/js/widget"], function(){' | |||
|
51 | 51 | |
|
52 | 52 | }); |
|
53 | 53 | |
|
54 |
IPython |
|
|
54 | IPython.widget_manager.register_widget_view('CheckboxView', CheckboxView); | |
|
55 | 55 | |
|
56 | 56 | var ToggleButtonView = IPython.WidgetView.extend({ |
|
57 | 57 | |
@@ -104,6 +104,6 b' require(["notebook/js/widget"], function(){' | |||
|
104 | 104 | }, |
|
105 | 105 | }); |
|
106 | 106 | |
|
107 |
IPython |
|
|
107 | IPython.widget_manager.register_widget_view('ToggleButtonView', ToggleButtonView); | |
|
108 | 108 | |
|
109 | 109 | }); |
@@ -1,8 +1,8 b'' | |||
|
1 | 1 | |
|
2 |
|
|
|
2 | define(["notebook/js/widget"], function(){ | |
|
3 | 3 | |
|
4 | 4 | var ButtonWidgetModel = IPython.WidgetModel.extend({}); |
|
5 |
IPython |
|
|
5 | IPython.widget_manager.register_widget_model('ButtonWidgetModel', ButtonWidgetModel); | |
|
6 | 6 | |
|
7 | 7 | var ButtonView = IPython.WidgetView.extend({ |
|
8 | 8 | |
@@ -34,6 +34,6 b' require(["notebook/js/widget"], function(){' | |||
|
34 | 34 | |
|
35 | 35 | }); |
|
36 | 36 | |
|
37 |
IPython |
|
|
37 | IPython.widget_manager.register_widget_view('ButtonView', ButtonView); | |
|
38 | 38 | |
|
39 | 39 | }); |
@@ -1,6 +1,6 b'' | |||
|
1 |
|
|
|
1 | define(["notebook/js/widget"], function(){ | |
|
2 | 2 | var ContainerModel = IPython.WidgetModel.extend({}); |
|
3 |
IPython |
|
|
3 | IPython.widget_manager.register_widget_model('ContainerWidgetModel', ContainerModel); | |
|
4 | 4 | |
|
5 | 5 | var ContainerView = IPython.WidgetView.extend({ |
|
6 | 6 | |
@@ -42,5 +42,5 b' require(["notebook/js/widget"], function(){' | |||
|
42 | 42 | }, |
|
43 | 43 | }); |
|
44 | 44 | |
|
45 |
IPython |
|
|
45 | IPython.widget_manager.register_widget_view('ContainerView', ContainerView); | |
|
46 | 46 | }); No newline at end of file |
@@ -1,4 +1,4 b'' | |||
|
1 |
|
|
|
1 | define(["notebook/js/widget"], function(){ | |
|
2 | 2 | var FloatWidgetModel = IPython.WidgetModel.extend({}); |
|
3 |
IPython |
|
|
3 | IPython.widget_manager.register_widget_model('FloatWidgetModel', FloatWidgetModel); | |
|
4 | 4 | }); No newline at end of file |
@@ -1,6 +1,6 b'' | |||
|
1 |
|
|
|
1 | define(["notebook/js/widget"], function(){ | |
|
2 | 2 | var FloatRangeWidgetModel = IPython.WidgetModel.extend({}); |
|
3 |
IPython |
|
|
3 | IPython.widget_manager.register_widget_model('FloatRangeWidgetModel', FloatRangeWidgetModel); | |
|
4 | 4 | |
|
5 | 5 | var FloatSliderView = IPython.WidgetView.extend({ |
|
6 | 6 | |
@@ -97,7 +97,7 b' require(["notebook/js/widget"], function(){' | |||
|
97 | 97 | }, |
|
98 | 98 | }); |
|
99 | 99 | |
|
100 |
IPython |
|
|
100 | IPython.widget_manager.register_widget_view('FloatSliderView', FloatSliderView); | |
|
101 | 101 | |
|
102 | 102 | |
|
103 | 103 | var FloatTextView = IPython.WidgetView.extend({ |
@@ -188,7 +188,7 b' require(["notebook/js/widget"], function(){' | |||
|
188 | 188 | } |
|
189 | 189 | }); |
|
190 | 190 | |
|
191 |
IPython |
|
|
191 | IPython.widget_manager.register_widget_view('FloatTextView', FloatTextView); | |
|
192 | 192 | |
|
193 | 193 | |
|
194 | 194 | var ProgressView = IPython.WidgetView.extend({ |
@@ -235,5 +235,5 b' require(["notebook/js/widget"], function(){' | |||
|
235 | 235 | |
|
236 | 236 | }); |
|
237 | 237 | |
|
238 |
IPython |
|
|
238 | IPython.widget_manager.register_widget_view('ProgressView', ProgressView); | |
|
239 | 239 | }); |
@@ -1,4 +1,4 b'' | |||
|
1 |
|
|
|
1 | define(["notebook/js/widget"], function(){ | |
|
2 | 2 | var IntWidgetModel = IPython.WidgetModel.extend({}); |
|
3 |
IPython |
|
|
3 | IPython.widget_manager.register_widget_model('IntWidgetModel', IntWidgetModel); | |
|
4 | 4 | }); No newline at end of file |
@@ -1,6 +1,6 b'' | |||
|
1 |
|
|
|
1 | define(["notebook/js/widget"], function(){ | |
|
2 | 2 | var IntRangeWidgetModel = IPython.WidgetModel.extend({}); |
|
3 |
IPython |
|
|
3 | IPython.widget_manager.register_widget_model('IntRangeWidgetModel', IntRangeWidgetModel); | |
|
4 | 4 | |
|
5 | 5 | var IntSliderView = IPython.WidgetView.extend({ |
|
6 | 6 | |
@@ -97,7 +97,7 b' require(["notebook/js/widget"], function(){' | |||
|
97 | 97 | }, |
|
98 | 98 | }); |
|
99 | 99 | |
|
100 |
IPython |
|
|
100 | IPython.widget_manager.register_widget_view('IntSliderView', IntSliderView); | |
|
101 | 101 | |
|
102 | 102 | var IntTextView = IPython.WidgetView.extend({ |
|
103 | 103 | |
@@ -187,5 +187,5 b' require(["notebook/js/widget"], function(){' | |||
|
187 | 187 | } |
|
188 | 188 | }); |
|
189 | 189 | |
|
190 |
IPython |
|
|
190 | IPython.widget_manager.register_widget_view('IntTextView', IntTextView); | |
|
191 | 191 | }); |
@@ -1,6 +1,6 b'' | |||
|
1 |
|
|
|
1 | define(["notebook/js/widget"], function(){ | |
|
2 | 2 | var MulticontainerModel = IPython.WidgetModel.extend({}); |
|
3 |
IPython |
|
|
3 | IPython.widget_manager.register_widget_model('MulticontainerWidgetModel', MulticontainerModel); | |
|
4 | 4 | |
|
5 | 5 | var AccordionView = IPython.WidgetView.extend({ |
|
6 | 6 | |
@@ -57,7 +57,7 b' require(["notebook/js/widget"], function(){' | |||
|
57 | 57 | }, |
|
58 | 58 | }); |
|
59 | 59 | |
|
60 |
IPython |
|
|
60 | IPython.widget_manager.register_widget_view('AccordionView', AccordionView); | |
|
61 | 61 | |
|
62 | 62 | var TabView = IPython.WidgetView.extend({ |
|
63 | 63 | |
@@ -134,6 +134,6 b' require(["notebook/js/widget"], function(){' | |||
|
134 | 134 | }, |
|
135 | 135 | }); |
|
136 | 136 | |
|
137 |
IPython |
|
|
137 | IPython.widget_manager.register_widget_view('TabView', TabView); | |
|
138 | 138 | |
|
139 | 139 | }); |
@@ -1,6 +1,6 b'' | |||
|
1 |
|
|
|
1 | define(["notebook/js/widget"], function(){ | |
|
2 | 2 | var SelectionWidgetModel = IPython.WidgetModel.extend({}); |
|
3 |
IPython |
|
|
3 | IPython.widget_manager.register_widget_model('SelectionWidgetModel', SelectionWidgetModel); | |
|
4 | 4 | |
|
5 | 5 | var DropdownView = IPython.WidgetView.extend({ |
|
6 | 6 | |
@@ -80,7 +80,7 b' require(["notebook/js/widget"], function(){' | |||
|
80 | 80 | |
|
81 | 81 | }); |
|
82 | 82 | |
|
83 |
IPython |
|
|
83 | IPython.widget_manager.register_widget_view('DropdownView', DropdownView); | |
|
84 | 84 | |
|
85 | 85 | var RadioButtonsView = IPython.WidgetView.extend({ |
|
86 | 86 | |
@@ -165,7 +165,7 b' require(["notebook/js/widget"], function(){' | |||
|
165 | 165 | |
|
166 | 166 | }); |
|
167 | 167 | |
|
168 |
IPython |
|
|
168 | IPython.widget_manager.register_widget_view('RadioButtonsView', RadioButtonsView); | |
|
169 | 169 | |
|
170 | 170 | |
|
171 | 171 | var ToggleButtonsView = IPython.WidgetView.extend({ |
@@ -247,5 +247,5 b' require(["notebook/js/widget"], function(){' | |||
|
247 | 247 | |
|
248 | 248 | }); |
|
249 | 249 | |
|
250 |
IPython |
|
|
250 | IPython.widget_manager.register_widget_view('ToggleButtonsView', ToggleButtonsView); | |
|
251 | 251 | }); |
@@ -1,6 +1,6 b'' | |||
|
1 |
|
|
|
1 | define(["notebook/js/widget"], function(){ | |
|
2 | 2 | var StringWidgetModel = IPython.WidgetModel.extend({}); |
|
3 |
IPython |
|
|
3 | IPython.widget_manager.register_widget_model('StringWidgetModel', StringWidgetModel); | |
|
4 | 4 | |
|
5 | 5 | var LabelView = IPython.WidgetView.extend({ |
|
6 | 6 | |
@@ -19,7 +19,7 b' require(["notebook/js/widget"], function(){' | |||
|
19 | 19 | |
|
20 | 20 | }); |
|
21 | 21 | |
|
22 |
IPython |
|
|
22 | IPython.widget_manager.register_widget_view('LabelView', LabelView); | |
|
23 | 23 | |
|
24 | 24 | var TextAreaView = IPython.WidgetView.extend({ |
|
25 | 25 | |
@@ -73,7 +73,7 b' require(["notebook/js/widget"], function(){' | |||
|
73 | 73 | }, |
|
74 | 74 | }); |
|
75 | 75 | |
|
76 |
IPython |
|
|
76 | IPython.widget_manager.register_widget_view('TextAreaView', TextAreaView); | |
|
77 | 77 | |
|
78 | 78 | var TextBoxView = IPython.WidgetView.extend({ |
|
79 | 79 | |
@@ -127,5 +127,5 b' require(["notebook/js/widget"], function(){' | |||
|
127 | 127 | }, |
|
128 | 128 | }); |
|
129 | 129 | |
|
130 |
IPython |
|
|
130 | IPython.widget_manager.register_widget_view('TextBoxView', TextBoxView); | |
|
131 | 131 | }); |
@@ -1,4 +1,4 b'' | |||
|
1 |
from .widget import Widget |
|
|
1 | from .widget import Widget | |
|
2 | 2 | |
|
3 | 3 | from .widget_bool import BoolWidget |
|
4 | 4 | from .widget_button import ButtonWidget |
@@ -26,19 +26,6 b' from IPython.utils.traitlets import Unicode, Dict, List, Instance, Bool' | |||
|
26 | 26 | from IPython.display import Javascript, display |
|
27 | 27 | from IPython.utils.py3compat import string_types |
|
28 | 28 | |
|
29 | #----------------------------------------------------------------------------- | |
|
30 | # Shared | |
|
31 | #----------------------------------------------------------------------------- | |
|
32 | def init_widget_js(): | |
|
33 | path = os.path.split(os.path.abspath( __file__ ))[0] | |
|
34 | for filepath in glob(os.path.join(path, "*.py")): | |
|
35 | filename = os.path.split(filepath)[1] | |
|
36 | name = filename.rsplit('.', 1)[0] | |
|
37 | if not (name == 'widget' or name == '__init__') and name.startswith('widget_'): | |
|
38 | # Remove 'widget_' from the start of the name before compiling the path. | |
|
39 | js_path = 'static/notebook/js/widgets/%s.js' % name[7:] | |
|
40 | display(Javascript(data='$.getScript($("body").data("baseProjectUrl") + "%s");' % js_path), exclude="text/plain") | |
|
41 | ||
|
42 | 29 | |
|
43 | 30 | #----------------------------------------------------------------------------- |
|
44 | 31 | # Classes |
@@ -18,85 +18,11 b'' | |||
|
18 | 18 | "collapsed": false, |
|
19 | 19 | "input": [ |
|
20 | 20 | "from IPython.html import widgets # Widget definitions\n", |
|
21 |
"from IPython.display import display # Used to display widgets in the notebook |
|
|
22 | "\n", | |
|
23 | "# Enable widgets in this notebook\n", | |
|
24 | "widgets.init_widget_js()" | |
|
21 | "from IPython.display import display # Used to display widgets in the notebook" | |
|
25 | 22 | ], |
|
26 | 23 | "language": "python", |
|
27 | 24 | "metadata": {}, |
|
28 | "outputs": [ | |
|
29 | { | |
|
30 | "javascript": [ | |
|
31 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/button.js\");" | |
|
32 | ], | |
|
33 | "metadata": {}, | |
|
34 | "output_type": "display_data" | |
|
35 | }, | |
|
36 | { | |
|
37 | "javascript": [ | |
|
38 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/int_range.js\");" | |
|
39 | ], | |
|
40 | "metadata": {}, | |
|
41 | "output_type": "display_data" | |
|
42 | }, | |
|
43 | { | |
|
44 | "javascript": [ | |
|
45 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/string.js\");" | |
|
46 | ], | |
|
47 | "metadata": {}, | |
|
48 | "output_type": "display_data" | |
|
49 | }, | |
|
50 | { | |
|
51 | "javascript": [ | |
|
52 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/multicontainer.js\");" | |
|
53 | ], | |
|
54 | "metadata": {}, | |
|
55 | "output_type": "display_data" | |
|
56 | }, | |
|
57 | { | |
|
58 | "javascript": [ | |
|
59 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/bool.js\");" | |
|
60 | ], | |
|
61 | "metadata": {}, | |
|
62 | "output_type": "display_data" | |
|
63 | }, | |
|
64 | { | |
|
65 | "javascript": [ | |
|
66 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/int.js\");" | |
|
67 | ], | |
|
68 | "metadata": {}, | |
|
69 | "output_type": "display_data" | |
|
70 | }, | |
|
71 | { | |
|
72 | "javascript": [ | |
|
73 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/selection.js\");" | |
|
74 | ], | |
|
75 | "metadata": {}, | |
|
76 | "output_type": "display_data" | |
|
77 | }, | |
|
78 | { | |
|
79 | "javascript": [ | |
|
80 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/float.js\");" | |
|
81 | ], | |
|
82 | "metadata": {}, | |
|
83 | "output_type": "display_data" | |
|
84 | }, | |
|
85 | { | |
|
86 | "javascript": [ | |
|
87 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/float_range.js\");" | |
|
88 | ], | |
|
89 | "metadata": {}, | |
|
90 | "output_type": "display_data" | |
|
91 | }, | |
|
92 | { | |
|
93 | "javascript": [ | |
|
94 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/container.js\");" | |
|
95 | ], | |
|
96 | "metadata": {}, | |
|
97 | "output_type": "display_data" | |
|
98 | } | |
|
99 | ], | |
|
25 | "outputs": [], | |
|
100 | 26 | "prompt_number": 1 |
|
101 | 27 | }, |
|
102 | 28 | { |
@@ -141,7 +67,7 b'' | |||
|
141 | 67 | " \n", |
|
142 | 68 | " // Define the FileModel and register it with the widget manager.\n", |
|
143 | 69 | " var FileModel = IPython.WidgetModel.extend({});\n", |
|
144 |
" IPython. |
|
|
70 | " IPython.widget_manager.register_widget_model('FileWidgetModel', FileModel);\n", | |
|
145 | 71 | " \n", |
|
146 | 72 | " // Define the FilePickerView\n", |
|
147 | 73 | " var FilePickerView = IPython.WidgetView.extend({\n", |
@@ -176,7 +102,7 b'' | |||
|
176 | 102 | " });\n", |
|
177 | 103 | " \n", |
|
178 | 104 | " // Register the DatePickerView with the widget manager.\n", |
|
179 |
" IPython. |
|
|
105 | " IPython.widget_manager.register_widget_view('FilePickerView', FilePickerView);\n", | |
|
180 | 106 | "});" |
|
181 | 107 | ], |
|
182 | 108 | "language": "python", |
@@ -189,7 +115,7 b'' | |||
|
189 | 115 | " \n", |
|
190 | 116 | " // Define the FileModel and register it with the widget manager.\n", |
|
191 | 117 | " var FileModel = IPython.WidgetModel.extend({});\n", |
|
192 |
" IPython. |
|
|
118 | " IPython.widget_manager.register_widget_model('FileWidgetModel', FileModel);\n", | |
|
193 | 119 | " \n", |
|
194 | 120 | " // Define the FilePickerView\n", |
|
195 | 121 | " var FilePickerView = IPython.WidgetView.extend({\n", |
@@ -202,7 +128,6 b'' | |||
|
202 | 128 | " },\n", |
|
203 | 129 | " \n", |
|
204 | 130 | " // Handles: User input\n", |
|
205 | " events: { \"change\" : \"handleFileChange\" }, \n", | |
|
206 | 131 | " handleFileChange: function(evt) { \n", |
|
207 | 132 | " \n", |
|
208 | 133 | " //Retrieve the first (and only!) File from the FileList object\n", |
@@ -225,13 +150,13 b'' | |||
|
225 | 150 | " });\n", |
|
226 | 151 | " \n", |
|
227 | 152 | " // Register the DatePickerView with the widget manager.\n", |
|
228 |
" IPython. |
|
|
153 | " IPython.widget_manager.register_widget_view('FilePickerView', FilePickerView);\n", | |
|
229 | 154 | "});" |
|
230 | 155 | ], |
|
231 | 156 | "metadata": {}, |
|
232 | 157 | "output_type": "display_data", |
|
233 | 158 | "text": [ |
|
234 |
"<IPython.core.display.Javascript at 0x |
|
|
159 | "<IPython.core.display.Javascript at 0x319fe90>" | |
|
235 | 160 | ] |
|
236 | 161 | } |
|
237 | 162 | ], |
@@ -1,5 +1,11 b'' | |||
|
1 | 1 | { |
|
2 | 2 | "metadata": { |
|
3 | "cell_tags": [ | |
|
4 | [ | |
|
5 | "<None>", | |
|
6 | null | |
|
7 | ] | |
|
8 | ], | |
|
3 | 9 | "name": "" |
|
4 | 10 | }, |
|
5 | 11 | "nbformat": 3, |
@@ -11,7 +17,7 b'' | |||
|
11 | 17 | "cell_type": "markdown", |
|
12 | 18 | "metadata": {}, |
|
13 | 19 | "source": [ |
|
14 | "To enable the use IPython widgets in the notebook, the widget namespace and display function need to be imported. The Javascript dependencies need to be loaded via `IPython.html.widgets.init_widget_js()`. This method needs to be called each time the notebook webpage is refreshed." | |
|
20 | "To use IPython widgets in the notebook, the widget namespace and display function need to be imported." | |
|
15 | 21 | ] |
|
16 | 22 | }, |
|
17 | 23 | { |
@@ -19,85 +25,11 b'' | |||
|
19 | 25 | "collapsed": false, |
|
20 | 26 | "input": [ |
|
21 | 27 | "from IPython.html import widgets # Widget definitions\n", |
|
22 |
"from IPython.display import display # Used to display widgets in the notebook |
|
|
23 | "\n", | |
|
24 | "# Enable widgets in this notebook\n", | |
|
25 | "widgets.init_widget_js()" | |
|
28 | "from IPython.display import display # Used to display widgets in the notebook" | |
|
26 | 29 | ], |
|
27 | 30 | "language": "python", |
|
28 | 31 | "metadata": {}, |
|
29 | "outputs": [ | |
|
30 | { | |
|
31 | "javascript": [ | |
|
32 | "$.getScript(\"/static/notebook/js/widgets/bool.js\");" | |
|
33 | ], | |
|
34 | "metadata": {}, | |
|
35 | "output_type": "display_data" | |
|
36 | }, | |
|
37 | { | |
|
38 | "javascript": [ | |
|
39 | "$.getScript(\"/static/notebook/js/widgets/int_range.js\");" | |
|
40 | ], | |
|
41 | "metadata": {}, | |
|
42 | "output_type": "display_data" | |
|
43 | }, | |
|
44 | { | |
|
45 | "javascript": [ | |
|
46 | "$.getScript(\"/static/notebook/js/widgets/int.js\");" | |
|
47 | ], | |
|
48 | "metadata": {}, | |
|
49 | "output_type": "display_data" | |
|
50 | }, | |
|
51 | { | |
|
52 | "javascript": [ | |
|
53 | "$.getScript(\"/static/notebook/js/widgets/selection.js\");" | |
|
54 | ], | |
|
55 | "metadata": {}, | |
|
56 | "output_type": "display_data" | |
|
57 | }, | |
|
58 | { | |
|
59 | "javascript": [ | |
|
60 | "$.getScript(\"/static/notebook/js/widgets/string.js\");" | |
|
61 | ], | |
|
62 | "metadata": {}, | |
|
63 | "output_type": "display_data" | |
|
64 | }, | |
|
65 | { | |
|
66 | "javascript": [ | |
|
67 | "$.getScript(\"/static/notebook/js/widgets/float.js\");" | |
|
68 | ], | |
|
69 | "metadata": {}, | |
|
70 | "output_type": "display_data" | |
|
71 | }, | |
|
72 | { | |
|
73 | "javascript": [ | |
|
74 | "$.getScript(\"/static/notebook/js/widgets/container.js\");" | |
|
75 | ], | |
|
76 | "metadata": {}, | |
|
77 | "output_type": "display_data" | |
|
78 | }, | |
|
79 | { | |
|
80 | "javascript": [ | |
|
81 | "$.getScript(\"/static/notebook/js/widgets/multicontainer.js\");" | |
|
82 | ], | |
|
83 | "metadata": {}, | |
|
84 | "output_type": "display_data" | |
|
85 | }, | |
|
86 | { | |
|
87 | "javascript": [ | |
|
88 | "$.getScript(\"/static/notebook/js/widgets/button.js\");" | |
|
89 | ], | |
|
90 | "metadata": {}, | |
|
91 | "output_type": "display_data" | |
|
92 | }, | |
|
93 | { | |
|
94 | "javascript": [ | |
|
95 | "$.getScript(\"/static/notebook/js/widgets/float_range.js\");" | |
|
96 | ], | |
|
97 | "metadata": {}, | |
|
98 | "output_type": "display_data" | |
|
99 | } | |
|
100 | ], | |
|
32 | "outputs": [], | |
|
101 | 33 | "prompt_number": 1 |
|
102 | 34 | }, |
|
103 | 35 | { |
@@ -1,5 +1,11 b'' | |||
|
1 | 1 | { |
|
2 | 2 | "metadata": { |
|
3 | "cell_tags": [ | |
|
4 | [ | |
|
5 | "<None>", | |
|
6 | null | |
|
7 | ] | |
|
8 | ], | |
|
3 | 9 | "name": "" |
|
4 | 10 | }, |
|
5 | 11 | "nbformat": 3, |
@@ -12,85 +18,11 b'' | |||
|
12 | 18 | "collapsed": false, |
|
13 | 19 | "input": [ |
|
14 | 20 | "from IPython.html import widgets # Widget definitions\n", |
|
15 |
"from IPython.display import display # Used to display widgets in the notebook |
|
|
16 | "\n", | |
|
17 | "# Enable widgets in this notebook\n", | |
|
18 | "widgets.init_widget_js()" | |
|
21 | "from IPython.display import display # Used to display widgets in the notebook" | |
|
19 | 22 | ], |
|
20 | 23 | "language": "python", |
|
21 | 24 | "metadata": {}, |
|
22 | "outputs": [ | |
|
23 | { | |
|
24 | "javascript": [ | |
|
25 | "$.getScript(\"/static/notebook/js/widgets/bool.js\");" | |
|
26 | ], | |
|
27 | "metadata": {}, | |
|
28 | "output_type": "display_data" | |
|
29 | }, | |
|
30 | { | |
|
31 | "javascript": [ | |
|
32 | "$.getScript(\"/static/notebook/js/widgets/int_range.js\");" | |
|
33 | ], | |
|
34 | "metadata": {}, | |
|
35 | "output_type": "display_data" | |
|
36 | }, | |
|
37 | { | |
|
38 | "javascript": [ | |
|
39 | "$.getScript(\"/static/notebook/js/widgets/int.js\");" | |
|
40 | ], | |
|
41 | "metadata": {}, | |
|
42 | "output_type": "display_data" | |
|
43 | }, | |
|
44 | { | |
|
45 | "javascript": [ | |
|
46 | "$.getScript(\"/static/notebook/js/widgets/selection.js\");" | |
|
47 | ], | |
|
48 | "metadata": {}, | |
|
49 | "output_type": "display_data" | |
|
50 | }, | |
|
51 | { | |
|
52 | "javascript": [ | |
|
53 | "$.getScript(\"/static/notebook/js/widgets/string.js\");" | |
|
54 | ], | |
|
55 | "metadata": {}, | |
|
56 | "output_type": "display_data" | |
|
57 | }, | |
|
58 | { | |
|
59 | "javascript": [ | |
|
60 | "$.getScript(\"/static/notebook/js/widgets/float.js\");" | |
|
61 | ], | |
|
62 | "metadata": {}, | |
|
63 | "output_type": "display_data" | |
|
64 | }, | |
|
65 | { | |
|
66 | "javascript": [ | |
|
67 | "$.getScript(\"/static/notebook/js/widgets/container.js\");" | |
|
68 | ], | |
|
69 | "metadata": {}, | |
|
70 | "output_type": "display_data" | |
|
71 | }, | |
|
72 | { | |
|
73 | "javascript": [ | |
|
74 | "$.getScript(\"/static/notebook/js/widgets/multicontainer.js\");" | |
|
75 | ], | |
|
76 | "metadata": {}, | |
|
77 | "output_type": "display_data" | |
|
78 | }, | |
|
79 | { | |
|
80 | "javascript": [ | |
|
81 | "$.getScript(\"/static/notebook/js/widgets/button.js\");" | |
|
82 | ], | |
|
83 | "metadata": {}, | |
|
84 | "output_type": "display_data" | |
|
85 | }, | |
|
86 | { | |
|
87 | "javascript": [ | |
|
88 | "$.getScript(\"/static/notebook/js/widgets/float_range.js\");" | |
|
89 | ], | |
|
90 | "metadata": {}, | |
|
91 | "output_type": "display_data" | |
|
92 | } | |
|
93 | ], | |
|
25 | "outputs": [], | |
|
94 | 26 | "prompt_number": 1 |
|
95 | 27 | }, |
|
96 | 28 | { |
@@ -1,5 +1,11 b'' | |||
|
1 | 1 | { |
|
2 | 2 | "metadata": { |
|
3 | "cell_tags": [ | |
|
4 | [ | |
|
5 | "<None>", | |
|
6 | null | |
|
7 | ] | |
|
8 | ], | |
|
3 | 9 | "name": "" |
|
4 | 10 | }, |
|
5 | 11 | "nbformat": 3, |
@@ -12,85 +18,11 b'' | |||
|
12 | 18 | "collapsed": false, |
|
13 | 19 | "input": [ |
|
14 | 20 | "from IPython.html import widgets # Widget definitions\n", |
|
15 |
"from IPython.display import display # Used to display widgets in the notebook |
|
|
16 | "\n", | |
|
17 | "# Enable widgets in this notebook\n", | |
|
18 | "widgets.init_widget_js()" | |
|
21 | "from IPython.display import display # Used to display widgets in the notebook" | |
|
19 | 22 | ], |
|
20 | 23 | "language": "python", |
|
21 | 24 | "metadata": {}, |
|
22 | "outputs": [ | |
|
23 | { | |
|
24 | "javascript": [ | |
|
25 | "$.getScript(\"/static/notebook/js/widgets/bool.js\");" | |
|
26 | ], | |
|
27 | "metadata": {}, | |
|
28 | "output_type": "display_data" | |
|
29 | }, | |
|
30 | { | |
|
31 | "javascript": [ | |
|
32 | "$.getScript(\"/static/notebook/js/widgets/int_range.js\");" | |
|
33 | ], | |
|
34 | "metadata": {}, | |
|
35 | "output_type": "display_data" | |
|
36 | }, | |
|
37 | { | |
|
38 | "javascript": [ | |
|
39 | "$.getScript(\"/static/notebook/js/widgets/int.js\");" | |
|
40 | ], | |
|
41 | "metadata": {}, | |
|
42 | "output_type": "display_data" | |
|
43 | }, | |
|
44 | { | |
|
45 | "javascript": [ | |
|
46 | "$.getScript(\"/static/notebook/js/widgets/selection.js\");" | |
|
47 | ], | |
|
48 | "metadata": {}, | |
|
49 | "output_type": "display_data" | |
|
50 | }, | |
|
51 | { | |
|
52 | "javascript": [ | |
|
53 | "$.getScript(\"/static/notebook/js/widgets/string.js\");" | |
|
54 | ], | |
|
55 | "metadata": {}, | |
|
56 | "output_type": "display_data" | |
|
57 | }, | |
|
58 | { | |
|
59 | "javascript": [ | |
|
60 | "$.getScript(\"/static/notebook/js/widgets/float.js\");" | |
|
61 | ], | |
|
62 | "metadata": {}, | |
|
63 | "output_type": "display_data" | |
|
64 | }, | |
|
65 | { | |
|
66 | "javascript": [ | |
|
67 | "$.getScript(\"/static/notebook/js/widgets/container.js\");" | |
|
68 | ], | |
|
69 | "metadata": {}, | |
|
70 | "output_type": "display_data" | |
|
71 | }, | |
|
72 | { | |
|
73 | "javascript": [ | |
|
74 | "$.getScript(\"/static/notebook/js/widgets/multicontainer.js\");" | |
|
75 | ], | |
|
76 | "metadata": {}, | |
|
77 | "output_type": "display_data" | |
|
78 | }, | |
|
79 | { | |
|
80 | "javascript": [ | |
|
81 | "$.getScript(\"/static/notebook/js/widgets/button.js\");" | |
|
82 | ], | |
|
83 | "metadata": {}, | |
|
84 | "output_type": "display_data" | |
|
85 | }, | |
|
86 | { | |
|
87 | "javascript": [ | |
|
88 | "$.getScript(\"/static/notebook/js/widgets/float_range.js\");" | |
|
89 | ], | |
|
90 | "metadata": {}, | |
|
91 | "output_type": "display_data" | |
|
92 | } | |
|
93 | ], | |
|
25 | "outputs": [], | |
|
94 | 26 | "prompt_number": 1 |
|
95 | 27 | }, |
|
96 | 28 | { |
@@ -1,5 +1,11 b'' | |||
|
1 | 1 | { |
|
2 | 2 | "metadata": { |
|
3 | "cell_tags": [ | |
|
4 | [ | |
|
5 | "<None>", | |
|
6 | null | |
|
7 | ] | |
|
8 | ], | |
|
3 | 9 | "name": "" |
|
4 | 10 | }, |
|
5 | 11 | "nbformat": 3, |
@@ -12,85 +18,11 b'' | |||
|
12 | 18 | "collapsed": false, |
|
13 | 19 | "input": [ |
|
14 | 20 | "from IPython.html import widgets # Widget definitions\n", |
|
15 |
"from IPython.display import display # Used to display widgets in the notebook |
|
|
16 | "\n", | |
|
17 | "# Enable widgets in this notebook\n", | |
|
18 | "widgets.init_widget_js()" | |
|
21 | "from IPython.display import display # Used to display widgets in the notebook" | |
|
19 | 22 | ], |
|
20 | 23 | "language": "python", |
|
21 | 24 | "metadata": {}, |
|
22 | "outputs": [ | |
|
23 | { | |
|
24 | "javascript": [ | |
|
25 | "$.getScript(\"../static/notebook/js/widgets/bool.js\");" | |
|
26 | ], | |
|
27 | "metadata": {}, | |
|
28 | "output_type": "display_data" | |
|
29 | }, | |
|
30 | { | |
|
31 | "javascript": [ | |
|
32 | "$.getScript(\"../static/notebook/js/widgets/int_range.js\");" | |
|
33 | ], | |
|
34 | "metadata": {}, | |
|
35 | "output_type": "display_data" | |
|
36 | }, | |
|
37 | { | |
|
38 | "javascript": [ | |
|
39 | "$.getScript(\"../static/notebook/js/widgets/int.js\");" | |
|
40 | ], | |
|
41 | "metadata": {}, | |
|
42 | "output_type": "display_data" | |
|
43 | }, | |
|
44 | { | |
|
45 | "javascript": [ | |
|
46 | "$.getScript(\"../static/notebook/js/widgets/selection.js\");" | |
|
47 | ], | |
|
48 | "metadata": {}, | |
|
49 | "output_type": "display_data" | |
|
50 | }, | |
|
51 | { | |
|
52 | "javascript": [ | |
|
53 | "$.getScript(\"../static/notebook/js/widgets/string.js\");" | |
|
54 | ], | |
|
55 | "metadata": {}, | |
|
56 | "output_type": "display_data" | |
|
57 | }, | |
|
58 | { | |
|
59 | "javascript": [ | |
|
60 | "$.getScript(\"../static/notebook/js/widgets/float.js\");" | |
|
61 | ], | |
|
62 | "metadata": {}, | |
|
63 | "output_type": "display_data" | |
|
64 | }, | |
|
65 | { | |
|
66 | "javascript": [ | |
|
67 | "$.getScript(\"../static/notebook/js/widgets/container.js\");" | |
|
68 | ], | |
|
69 | "metadata": {}, | |
|
70 | "output_type": "display_data" | |
|
71 | }, | |
|
72 | { | |
|
73 | "javascript": [ | |
|
74 | "$.getScript(\"../static/notebook/js/widgets/multicontainer.js\");" | |
|
75 | ], | |
|
76 | "metadata": {}, | |
|
77 | "output_type": "display_data" | |
|
78 | }, | |
|
79 | { | |
|
80 | "javascript": [ | |
|
81 | "$.getScript(\"../static/notebook/js/widgets/button.js\");" | |
|
82 | ], | |
|
83 | "metadata": {}, | |
|
84 | "output_type": "display_data" | |
|
85 | }, | |
|
86 | { | |
|
87 | "javascript": [ | |
|
88 | "$.getScript(\"../static/notebook/js/widgets/float_range.js\");" | |
|
89 | ], | |
|
90 | "metadata": {}, | |
|
91 | "output_type": "display_data" | |
|
92 | } | |
|
93 | ], | |
|
25 | "outputs": [], | |
|
94 | 26 | "prompt_number": 1 |
|
95 | 27 | }, |
|
96 | 28 | { |
@@ -18,85 +18,11 b'' | |||
|
18 | 18 | "collapsed": false, |
|
19 | 19 | "input": [ |
|
20 | 20 | "from IPython.html import widgets # Widget definitions\n", |
|
21 |
"from IPython.display import display # Used to display widgets in the notebook |
|
|
22 | "\n", | |
|
23 | "# Enable widgets in this notebook\n", | |
|
24 | "widgets.init_widget_js()" | |
|
21 | "from IPython.display import display # Used to display widgets in the notebook" | |
|
25 | 22 | ], |
|
26 | 23 | "language": "python", |
|
27 | 24 | "metadata": {}, |
|
28 | "outputs": [ | |
|
29 | { | |
|
30 | "javascript": [ | |
|
31 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/button.js\");" | |
|
32 | ], | |
|
33 | "metadata": {}, | |
|
34 | "output_type": "display_data" | |
|
35 | }, | |
|
36 | { | |
|
37 | "javascript": [ | |
|
38 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/int_range.js\");" | |
|
39 | ], | |
|
40 | "metadata": {}, | |
|
41 | "output_type": "display_data" | |
|
42 | }, | |
|
43 | { | |
|
44 | "javascript": [ | |
|
45 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/string.js\");" | |
|
46 | ], | |
|
47 | "metadata": {}, | |
|
48 | "output_type": "display_data" | |
|
49 | }, | |
|
50 | { | |
|
51 | "javascript": [ | |
|
52 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/multicontainer.js\");" | |
|
53 | ], | |
|
54 | "metadata": {}, | |
|
55 | "output_type": "display_data" | |
|
56 | }, | |
|
57 | { | |
|
58 | "javascript": [ | |
|
59 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/bool.js\");" | |
|
60 | ], | |
|
61 | "metadata": {}, | |
|
62 | "output_type": "display_data" | |
|
63 | }, | |
|
64 | { | |
|
65 | "javascript": [ | |
|
66 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/int.js\");" | |
|
67 | ], | |
|
68 | "metadata": {}, | |
|
69 | "output_type": "display_data" | |
|
70 | }, | |
|
71 | { | |
|
72 | "javascript": [ | |
|
73 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/selection.js\");" | |
|
74 | ], | |
|
75 | "metadata": {}, | |
|
76 | "output_type": "display_data" | |
|
77 | }, | |
|
78 | { | |
|
79 | "javascript": [ | |
|
80 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/float.js\");" | |
|
81 | ], | |
|
82 | "metadata": {}, | |
|
83 | "output_type": "display_data" | |
|
84 | }, | |
|
85 | { | |
|
86 | "javascript": [ | |
|
87 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/float_range.js\");" | |
|
88 | ], | |
|
89 | "metadata": {}, | |
|
90 | "output_type": "display_data" | |
|
91 | }, | |
|
92 | { | |
|
93 | "javascript": [ | |
|
94 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/container.js\");" | |
|
95 | ], | |
|
96 | "metadata": {}, | |
|
97 | "output_type": "display_data" | |
|
98 | } | |
|
99 | ], | |
|
25 | "outputs": [], | |
|
100 | 26 | "prompt_number": 1 |
|
101 | 27 | }, |
|
102 | 28 | { |
@@ -30,85 +30,11 b'' | |||
|
30 | 30 | "collapsed": false, |
|
31 | 31 | "input": [ |
|
32 | 32 | "from IPython.html import widgets # Widget definitions\n", |
|
33 |
"from IPython.display import display # Used to display widgets in the notebook |
|
|
34 | "\n", | |
|
35 | "# Enable widgets in this notebook\n", | |
|
36 | "widgets.init_widget_js()" | |
|
33 | "from IPython.display import display # Used to display widgets in the notebook" | |
|
37 | 34 | ], |
|
38 | 35 | "language": "python", |
|
39 | 36 | "metadata": {}, |
|
40 | "outputs": [ | |
|
41 | { | |
|
42 | "javascript": [ | |
|
43 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/button.js\");" | |
|
44 | ], | |
|
45 | "metadata": {}, | |
|
46 | "output_type": "display_data" | |
|
47 | }, | |
|
48 | { | |
|
49 | "javascript": [ | |
|
50 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/int_range.js\");" | |
|
51 | ], | |
|
52 | "metadata": {}, | |
|
53 | "output_type": "display_data" | |
|
54 | }, | |
|
55 | { | |
|
56 | "javascript": [ | |
|
57 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/string.js\");" | |
|
58 | ], | |
|
59 | "metadata": {}, | |
|
60 | "output_type": "display_data" | |
|
61 | }, | |
|
62 | { | |
|
63 | "javascript": [ | |
|
64 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/multicontainer.js\");" | |
|
65 | ], | |
|
66 | "metadata": {}, | |
|
67 | "output_type": "display_data" | |
|
68 | }, | |
|
69 | { | |
|
70 | "javascript": [ | |
|
71 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/bool.js\");" | |
|
72 | ], | |
|
73 | "metadata": {}, | |
|
74 | "output_type": "display_data" | |
|
75 | }, | |
|
76 | { | |
|
77 | "javascript": [ | |
|
78 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/int.js\");" | |
|
79 | ], | |
|
80 | "metadata": {}, | |
|
81 | "output_type": "display_data" | |
|
82 | }, | |
|
83 | { | |
|
84 | "javascript": [ | |
|
85 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/selection.js\");" | |
|
86 | ], | |
|
87 | "metadata": {}, | |
|
88 | "output_type": "display_data" | |
|
89 | }, | |
|
90 | { | |
|
91 | "javascript": [ | |
|
92 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/float.js\");" | |
|
93 | ], | |
|
94 | "metadata": {}, | |
|
95 | "output_type": "display_data" | |
|
96 | }, | |
|
97 | { | |
|
98 | "javascript": [ | |
|
99 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/float_range.js\");" | |
|
100 | ], | |
|
101 | "metadata": {}, | |
|
102 | "output_type": "display_data" | |
|
103 | }, | |
|
104 | { | |
|
105 | "javascript": [ | |
|
106 | "$.getScript($(\"body\").data(\"baseProjectUrl\") + \"static/notebook/js/widgets/container.js\");" | |
|
107 | ], | |
|
108 | "metadata": {}, | |
|
109 | "output_type": "display_data" | |
|
110 | } | |
|
111 | ], | |
|
37 | "outputs": [], | |
|
112 | 38 | "prompt_number": 1 |
|
113 | 39 | }, |
|
114 | 40 | { |
@@ -213,7 +139,7 b'' | |||
|
213 | 139 | "metadata": {}, |
|
214 | 140 | "output_type": "display_data", |
|
215 | 141 | "text": [ |
|
216 |
"<IPython.core.display.Javascript at 0x |
|
|
142 | "<IPython.core.display.Javascript at 0x21f8f10>" | |
|
217 | 143 | ] |
|
218 | 144 | } |
|
219 | 145 | ], |
@@ -236,7 +162,7 b'' | |||
|
236 | 162 | " \n", |
|
237 | 163 | " // Define the DateModel and register it with the widget manager.\n", |
|
238 | 164 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
239 |
" IPython. |
|
|
165 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
|
240 | 166 | "});" |
|
241 | 167 | ], |
|
242 | 168 | "language": "python", |
@@ -249,13 +175,13 b'' | |||
|
249 | 175 | " \n", |
|
250 | 176 | " // Define the DateModel and register it with the widget manager.\n", |
|
251 | 177 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
252 |
" IPython. |
|
|
178 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
|
253 | 179 | "});" |
|
254 | 180 | ], |
|
255 | 181 | "metadata": {}, |
|
256 | 182 | "output_type": "display_data", |
|
257 | 183 | "text": [ |
|
258 |
"<IPython.core.display.Javascript at 0x |
|
|
184 | "<IPython.core.display.Javascript at 0x21f8ed0>" | |
|
259 | 185 | ] |
|
260 | 186 | } |
|
261 | 187 | ], |
@@ -280,7 +206,7 b'' | |||
|
280 | 206 | " \n", |
|
281 | 207 | " // Define the DateModel and register it with the widget manager.\n", |
|
282 | 208 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
283 |
" IPython. |
|
|
209 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
|
284 | 210 | " \n", |
|
285 | 211 | " // Define the DatePickerView\n", |
|
286 | 212 | " var DatePickerView = IPython.WidgetView.extend({\n", |
@@ -292,7 +218,7 b'' | |||
|
292 | 218 | " });\n", |
|
293 | 219 | " \n", |
|
294 | 220 | " // Register the DatePickerView with the widget manager.\n", |
|
295 |
" IPython. |
|
|
221 | " IPython.widget_manager.register_widget_view('DatePickerView', DatePickerView);\n", | |
|
296 | 222 | "});" |
|
297 | 223 | ], |
|
298 | 224 | "language": "python", |
@@ -305,7 +231,7 b'' | |||
|
305 | 231 | " \n", |
|
306 | 232 | " // Define the DateModel and register it with the widget manager.\n", |
|
307 | 233 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
308 |
" IPython. |
|
|
234 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
|
309 | 235 | " \n", |
|
310 | 236 | " // Define the DatePickerView\n", |
|
311 | 237 | " var DatePickerView = IPython.WidgetView.extend({\n", |
@@ -317,13 +243,13 b'' | |||
|
317 | 243 | " });\n", |
|
318 | 244 | " \n", |
|
319 | 245 | " // Register the DatePickerView with the widget manager.\n", |
|
320 |
" IPython. |
|
|
246 | " IPython.widget_manager.register_widget_view('DatePickerView', DatePickerView);\n", | |
|
321 | 247 | "});" |
|
322 | 248 | ], |
|
323 | 249 | "metadata": {}, |
|
324 | 250 | "output_type": "display_data", |
|
325 | 251 | "text": [ |
|
326 |
"<IPython.core.display.Javascript at 0x |
|
|
252 | "<IPython.core.display.Javascript at 0x21f8cd0>" | |
|
327 | 253 | ] |
|
328 | 254 | } |
|
329 | 255 | ], |
@@ -426,7 +352,7 b'' | |||
|
426 | 352 | " \n", |
|
427 | 353 | " // Define the DateModel and register it with the widget manager.\n", |
|
428 | 354 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
429 |
" IPython. |
|
|
355 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
|
430 | 356 | " \n", |
|
431 | 357 | " // Define the DatePickerView\n", |
|
432 | 358 | " var DatePickerView = IPython.WidgetView.extend({\n", |
@@ -443,7 +369,7 b'' | |||
|
443 | 369 | " });\n", |
|
444 | 370 | " \n", |
|
445 | 371 | " // Register the DatePickerView with the widget manager.\n", |
|
446 |
" IPython. |
|
|
372 | " IPython.widget_manager.register_widget_view('DatePickerView', DatePickerView);\n", | |
|
447 | 373 | "});" |
|
448 | 374 | ], |
|
449 | 375 | "language": "python", |
@@ -456,7 +382,7 b'' | |||
|
456 | 382 | " \n", |
|
457 | 383 | " // Define the DateModel and register it with the widget manager.\n", |
|
458 | 384 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
459 |
" IPython. |
|
|
385 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
|
460 | 386 | " \n", |
|
461 | 387 | " // Define the DatePickerView\n", |
|
462 | 388 | " var DatePickerView = IPython.WidgetView.extend({\n", |
@@ -473,13 +399,13 b'' | |||
|
473 | 399 | " });\n", |
|
474 | 400 | " \n", |
|
475 | 401 | " // Register the DatePickerView with the widget manager.\n", |
|
476 |
" IPython. |
|
|
402 | " IPython.widget_manager.register_widget_view('DatePickerView', DatePickerView);\n", | |
|
477 | 403 | "});" |
|
478 | 404 | ], |
|
479 | 405 | "metadata": {}, |
|
480 | 406 | "output_type": "display_data", |
|
481 | 407 | "text": [ |
|
482 |
"<IPython.core.display.Javascript at 0x |
|
|
408 | "<IPython.core.display.Javascript at 0x21fc310>" | |
|
483 | 409 | ] |
|
484 | 410 | } |
|
485 | 411 | ], |
@@ -502,7 +428,7 b'' | |||
|
502 | 428 | " \n", |
|
503 | 429 | " // Define the DateModel and register it with the widget manager.\n", |
|
504 | 430 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
505 |
" IPython. |
|
|
431 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
|
506 | 432 | " \n", |
|
507 | 433 | " // Define the DatePickerView\n", |
|
508 | 434 | " var DatePickerView = IPython.WidgetView.extend({\n", |
@@ -526,7 +452,7 b'' | |||
|
526 | 452 | " });\n", |
|
527 | 453 | " \n", |
|
528 | 454 | " // Register the DatePickerView with the widget manager.\n", |
|
529 |
" IPython. |
|
|
455 | " IPython.widget_manager.register_widget_view('DatePickerView', DatePickerView);\n", | |
|
530 | 456 | "});" |
|
531 | 457 | ], |
|
532 | 458 | "language": "python", |
@@ -539,7 +465,7 b'' | |||
|
539 | 465 | " \n", |
|
540 | 466 | " // Define the DateModel and register it with the widget manager.\n", |
|
541 | 467 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
542 |
" IPython. |
|
|
468 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
|
543 | 469 | " \n", |
|
544 | 470 | " // Define the DatePickerView\n", |
|
545 | 471 | " var DatePickerView = IPython.WidgetView.extend({\n", |
@@ -563,13 +489,13 b'' | |||
|
563 | 489 | " });\n", |
|
564 | 490 | " \n", |
|
565 | 491 | " // Register the DatePickerView with the widget manager.\n", |
|
566 |
" IPython. |
|
|
492 | " IPython.widget_manager.register_widget_view('DatePickerView', DatePickerView);\n", | |
|
567 | 493 | "});" |
|
568 | 494 | ], |
|
569 | 495 | "metadata": {}, |
|
570 | 496 | "output_type": "display_data", |
|
571 | 497 | "text": [ |
|
572 |
"<IPython.core.display.Javascript at 0x |
|
|
498 | "<IPython.core.display.Javascript at 0x21fc290>" | |
|
573 | 499 | ] |
|
574 | 500 | } |
|
575 | 501 | ], |
@@ -596,7 +522,7 b'' | |||
|
596 | 522 | " \n", |
|
597 | 523 | " // Define the DateModel and register it with the widget manager.\n", |
|
598 | 524 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
599 |
" IPython. |
|
|
525 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
|
600 | 526 | " \n", |
|
601 | 527 | " // Define the DatePickerView\n", |
|
602 | 528 | " var DatePickerView = IPython.WidgetView.extend({\n", |
@@ -632,7 +558,7 b'' | |||
|
632 | 558 | " });\n", |
|
633 | 559 | " \n", |
|
634 | 560 | " // Register the DatePickerView with the widget manager.\n", |
|
635 |
" IPython. |
|
|
561 | " IPython.widget_manager.register_widget_view('DatePickerView', DatePickerView);\n", | |
|
636 | 562 | "});" |
|
637 | 563 | ], |
|
638 | 564 | "language": "python", |
@@ -645,7 +571,7 b'' | |||
|
645 | 571 | " \n", |
|
646 | 572 | " // Define the DateModel and register it with the widget manager.\n", |
|
647 | 573 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
648 |
" IPython. |
|
|
574 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
|
649 | 575 | " \n", |
|
650 | 576 | " // Define the DatePickerView\n", |
|
651 | 577 | " var DatePickerView = IPython.WidgetView.extend({\n", |
@@ -681,13 +607,13 b'' | |||
|
681 | 607 | " });\n", |
|
682 | 608 | " \n", |
|
683 | 609 | " // Register the DatePickerView with the widget manager.\n", |
|
684 |
" IPython. |
|
|
610 | " IPython.widget_manager.register_widget_view('DatePickerView', DatePickerView);\n", | |
|
685 | 611 | "});" |
|
686 | 612 | ], |
|
687 | 613 | "metadata": {}, |
|
688 | 614 | "output_type": "display_data", |
|
689 | 615 | "text": [ |
|
690 |
"<IPython.core.display.Javascript at 0x |
|
|
616 | "<IPython.core.display.Javascript at 0x21fc3d0>" | |
|
691 | 617 | ] |
|
692 | 618 | } |
|
693 | 619 | ], |
@@ -759,7 +685,7 b'' | |||
|
759 | 685 | "output_type": "pyout", |
|
760 | 686 | "prompt_number": 13, |
|
761 | 687 | "text": [ |
|
762 | "u''" | |
|
688 | "u'2013-11-14'" | |
|
763 | 689 | ] |
|
764 | 690 | } |
|
765 | 691 | ], |
@@ -1041,7 +967,7 b'' | |||
|
1041 | 967 | " \n", |
|
1042 | 968 | " // Define the DateModel and register it with the widget manager.\n", |
|
1043 | 969 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
1044 |
" IPython. |
|
|
970 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
|
1045 | 971 | " \n", |
|
1046 | 972 | " // Define the DatePickerView\n", |
|
1047 | 973 | " var DatePickerView = IPython.WidgetView.extend({\n", |
@@ -1095,7 +1021,7 b'' | |||
|
1095 | 1021 | " });\n", |
|
1096 | 1022 | " \n", |
|
1097 | 1023 | " // Register the DatePickerView with the widget manager.\n", |
|
1098 |
" IPython. |
|
|
1024 | " IPython.widget_manager.register_widget_view('DatePickerView', DatePickerView);\n", | |
|
1099 | 1025 | "});" |
|
1100 | 1026 | ], |
|
1101 | 1027 | "language": "python", |
@@ -1108,7 +1034,7 b'' | |||
|
1108 | 1034 | " \n", |
|
1109 | 1035 | " // Define the DateModel and register it with the widget manager.\n", |
|
1110 | 1036 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
1111 |
" IPython. |
|
|
1037 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
|
1112 | 1038 | " \n", |
|
1113 | 1039 | " // Define the DatePickerView\n", |
|
1114 | 1040 | " var DatePickerView = IPython.WidgetView.extend({\n", |
@@ -1162,13 +1088,13 b'' | |||
|
1162 | 1088 | " });\n", |
|
1163 | 1089 | " \n", |
|
1164 | 1090 | " // Register the DatePickerView with the widget manager.\n", |
|
1165 |
" IPython. |
|
|
1091 | " IPython.widget_manager.register_widget_view('DatePickerView', DatePickerView);\n", | |
|
1166 | 1092 | "});" |
|
1167 | 1093 | ], |
|
1168 | 1094 | "metadata": {}, |
|
1169 | 1095 | "output_type": "display_data", |
|
1170 | 1096 | "text": [ |
|
1171 |
"<IPython.core.display.Javascript at 0x |
|
|
1097 | "<IPython.core.display.Javascript at 0x221a850>" | |
|
1172 | 1098 | ] |
|
1173 | 1099 | } |
|
1174 | 1100 | ], |
@@ -1216,7 +1142,6 b'' | |||
|
1216 | 1142 | "cell_type": "code", |
|
1217 | 1143 | "collapsed": false, |
|
1218 | 1144 | "input": [ |
|
1219 | "\n", | |
|
1220 | 1145 | "display(my_widget, view_name=\"TextBoxView\")" |
|
1221 | 1146 | ], |
|
1222 | 1147 | "language": "python", |
General Comments 0
You need to be logged in to leave comments.
Login now