Show More
@@ -14,7 +14,8 b'' | |||||
14 | // as injecting require.js make marked not to put itself in the globals, |
|
14 | // as injecting require.js make marked not to put itself in the globals, | |
15 | // which make both this file fail at setting marked configuration, and textcell.js |
|
15 | // which make both this file fail at setting marked configuration, and textcell.js | |
16 | // which search marked into global. |
|
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 | function (marked) { |
|
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 | Notebook.prototype._session_started = function(){ |
|
1302 | Notebook.prototype._session_started = function(){ | |
1302 | this.kernel = this.session.kernel; |
|
1303 | this.kernel = this.session.kernel; | |
|
1304 | IPython.widget_manager.attach_comm_manager(this.kernel.comm_manager); | |||
1303 | var ncells = this.ncells(); |
|
1305 | var ncells = this.ncells(); | |
1304 | for (var i=0; i<ncells; i++) { |
|
1306 | for (var i=0; i<ncells; i++) { | |
1305 | var cell = this.get_cell(i); |
|
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 | "components/backbone/backbone-min", |
|
24 | "components/backbone/backbone-min", | |
25 | ], function(){ |
|
25 | ], function(){ | |
26 |
|
26 | |||
27 | // Only run once on a notebook. |
|
27 | ||
28 | if (IPython.notebook.widget_manager == undefined) { |
|
28 | //-------------------------------------------------------------------- | |
29 |
|
29 | // WidgetModel class | ||
30 |
|
|
30 | //-------------------------------------------------------------------- | |
31 | // WidgetModel class |
|
31 | var WidgetModel = Backbone.Model.extend({ | |
32 | //-------------------------------------------------------------------- |
|
32 | constructor: function(comm_manager, comm, widget_view_types) { | |
33 | var WidgetModel = Backbone.Model.extend({ |
|
33 | this.comm_manager = comm_manager; | |
34 | constructor: function(comm_manager, comm, widget_view_types) { |
|
34 | this.widget_view_types = widget_view_types; | |
35 | this.comm_manager = comm_manager; |
|
35 | this.pending_msgs = 0; | |
36 | this.widget_view_types = widget_view_types; |
|
36 | this.msg_throttle = 3; | |
37 |
|
|
37 | this.msg_buffer = null; | |
38 |
|
|
38 | this.views = {}; | |
39 | this.msg_buffer = null; |
|
39 | ||
40 | this.views = {}; |
|
40 | // Remember comm associated with the model. | |
41 |
|
41 | this.comm = comm; | ||
42 | // Remember comm associated with the model. |
|
42 | comm.model = this; | |
43 | this.comm = comm; |
|
43 | ||
44 | comm.model = this; |
|
44 | // Hook comm messages up to model. | |
45 |
|
45 | comm.on_close($.proxy(this.handle_comm_closed, this)); | ||
46 | // Hook comm messages up to model. |
|
46 | comm.on_msg($.proxy(this.handle_comm_msg, this)); | |
47 | comm.on_close($.proxy(this.handle_comm_closed, this)); |
|
47 | ||
48 | comm.on_msg($.proxy(this.handle_comm_msg, this)); |
|
48 | return Backbone.Model.apply(this); | |
49 |
|
49 | }, | ||
50 | return Backbone.Model.apply(this); |
|
50 | ||
51 | }, |
|
51 | ||
52 |
|
52 | update_other_views: function(caller) { | ||
53 |
|
53 | this.last_modified_view = caller; | ||
54 | update_other_views: function(caller) { |
|
54 | this.save(this.changedAttributes(), {patch: true}); | |
55 | this.last_modified_view = caller; |
|
55 | ||
56 | this.save(this.changedAttributes(), {patch: true}); |
|
56 | for (var output_area in this.views) { | |
57 |
|
57 | var views = this.views[output_area]; | ||
58 |
for (var |
|
58 | for (var view_index in views) { | |
59 |
var view |
|
59 | var view = views[view_index]; | |
60 |
f |
|
60 | if (view !== caller) { | |
61 |
|
|
61 | view.update(); | |
62 | if (view !== caller) { |
|
|||
63 | view.update(); |
|
|||
64 | } |
|
|||
65 | } |
|
62 | } | |
66 | } |
|
63 | } | |
67 |
} |
|
64 | } | |
68 |
|
65 | }, | ||
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 { |
|
|||
86 |
|
66 | |||
87 | // Only decrease the pending message count if the buffer |
|
67 | ||
88 | // doesn't get flushed (sent). |
|
68 | handle_status: function (output_area, msg) { | |
89 | --this.pending_msgs; |
|
69 | //execution_state : ('busy', 'idle', 'starting') | |
90 | } |
|
70 | if (msg.content.execution_state=='idle') { | |
91 |
|
|
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 |
} |
|
89 | } | |
94 |
|
90 | }, | ||
95 |
|
91 | |||
96 | // Custom syncronization logic. |
|
92 | ||
97 | handle_sync: function (method, options) { |
|
93 | // Custom syncronization logic. | |
98 | var model_json = this.toJSON(); |
|
94 | handle_sync: function (method, options) { | |
99 |
|
95 | var model_json = this.toJSON(); | ||
100 | // Only send updated state if the state hasn't been changed |
|
96 | ||
101 | // during an update. |
|
97 | // Only send updated state if the state hasn't been changed | |
102 | if (!this.updating) { |
|
98 | // during an update. | |
103 | if (this.pending_msgs >= this.msg_throttle) { |
|
99 | if (!this.updating) { | |
104 | // The throttle has been exceeded, buffer the current msg so |
|
100 | if (this.pending_msgs >= this.msg_throttle) { | |
105 | // it can be sent once the kernel has finished processing |
|
101 | // The throttle has been exceeded, buffer the current msg so | |
106 | // some of the existing messages. |
|
102 | // it can be sent once the kernel has finished processing | |
107 | if (method=='patch') { |
|
103 | // some of the existing messages. | |
108 |
|
|
104 | if (method=='patch') { | |
109 |
|
|
105 | if (this.msg_buffer == null) { | |
110 | } |
|
|||
111 | for (var attr in options.attrs) { |
|
|||
112 | this.msg_buffer[attr] = options.attrs[attr]; |
|
|||
113 | } |
|
|||
114 | } else { |
|
|||
115 | this.msg_buffer = $.extend({}, model_json); // Copy |
|
106 | this.msg_buffer = $.extend({}, model_json); // Copy | |
116 | } |
|
107 | } | |
117 |
|
108 | for (var attr in options.attrs) { | ||
118 | } else { |
|
109 | this.msg_buffer[attr] = options.attrs[attr]; | |
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 | } |
|
|||
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}; |
|
115 | } else { | |
131 | var output_area = this.last_modified_view.output_area; |
|
116 | // We haven't exceeded the throttle, send the message like | |
132 | var callbacks = this._make_callbacks(output_area); |
|
117 | // normal. If this is a patch operation, just send the | |
133 | this.comm.send(data, callbacks); |
|
118 | // changes. | |
134 |
|
|
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 |
|
|
133 | } | |
138 | // Since the comm is a one-way communication, assume the message |
|
134 | ||
139 | // arrived. |
|
135 | // Since the comm is a one-way communication, assume the message | |
140 | return model_json; |
|
136 | // arrived. | |
141 | }, |
|
137 | return model_json; | |
142 |
|
138 | }, | ||
143 |
|
139 | |||
144 | // Handle incomming comm msg. |
|
140 | ||
145 | handle_comm_msg: function (msg) { |
|
141 | // Handle incomming comm msg. | |
146 | var method = msg.content.data.method; |
|
142 | handle_comm_msg: function (msg) { | |
147 | switch (method){ |
|
143 | var method = msg.content.data.method; | |
148 | case 'display': |
|
144 | switch (method){ | |
149 |
|
145 | case 'display': | ||
150 | // Try to get the cell index. |
|
146 | ||
151 | var output_area = this._get_output_area(msg.parent_header.msg_id); |
|
147 | // Try to get the cell index. | |
152 | if (output_area == null) { |
|
148 | var output_area = this._get_output_area(msg.parent_header.msg_id); | |
153 | console.log("Could not determine where the display" + |
|
149 | if (output_area == null) { | |
154 | " message was from. Widget will not be displayed") |
|
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 | } else { |
|
173 | } else { | |
156 |
this. |
|
174 | this.set(key, state[key]); | |
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 | } |
|
|||
179 | } |
|
175 | } | |
180 | } |
|
176 | } | |
181 | this.id = this.comm.comm_id; |
|
|||
182 | this.save(); |
|
|||
183 | } finally { |
|
|||
184 | this.updating = false; |
|
|||
185 | } |
|
177 | } | |
186 | }, |
|
178 | this.id = this.comm.comm_id; | |
187 |
|
179 | this.save(); | ||
188 |
|
180 | } finally { | ||
189 | // Handle when a widget is closed. |
|
181 | this.updating = false; | |
190 | handle_comm_closed: function (msg) { |
|
182 | } | |
191 | for (var output_area in this.views) { |
|
183 | }, | |
192 | var views = this.views[output_area]; |
|
184 | ||
193 | for (var view_index in views) { |
|
185 | ||
194 | var view = views[view_index]; |
|
186 | // Handle when a widget is closed. | |
195 | view.remove(); |
|
187 | handle_comm_closed: function (msg) { | |
196 | } |
|
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 |
} |
|
194 | } | |
199 |
|
195 | }, | ||
200 |
|
196 | |||
201 | // Create view that represents the model. |
|
197 | ||
202 | display_view: function (view_name, parent_comm_id, output_area) { |
|
198 | // Create view that represents the model. | |
203 | var new_views = []; |
|
199 | display_view: function (view_name, parent_comm_id, output_area) { | |
204 |
|
200 | var new_views = []; | ||
205 | var displayed = false; |
|
201 | ||
206 | if (parent_comm_id != undefined) { |
|
202 | var displayed = false; | |
207 | var parent_comm = this.comm_manager.comms[parent_comm_id]; |
|
203 | if (parent_comm_id != undefined) { | |
208 |
|
|
204 | var parent_comm = this.comm_manager.comms[parent_comm_id]; | |
209 |
|
|
205 | var parent_model = parent_comm.model; | |
210 |
|
|
206 | var parent_views = parent_model.views[output_area]; | |
211 | var parent_view = parent_views[parent_view_index]; |
|
207 | for (var parent_view_index in parent_views) { | |
212 | if (parent_view.display_child != undefined) { |
|
208 | var parent_view = parent_views[parent_view_index]; | |
213 | var view = this._create_view(view_name, output_area); |
|
209 | if (parent_view.display_child != undefined) { | |
214 |
|
|
210 | var view = this._create_view(view_name, output_area); | |
215 |
|
|
211 | new_views.push(view); | |
216 |
|
|
212 | parent_view.display_child(view); | |
217 |
|
|
213 | displayed = true; | |
218 | } |
|
214 | } | |
219 | } |
|
215 | } | |
220 |
|
216 | } | ||
221 | if (!displayed) { |
|
217 | ||
222 | // No parent view is defined or exists. Add the view's |
|
218 | if (!displayed) { | |
223 | // element to cell's widget div. |
|
219 | // No parent view is defined or exists. Add the view's | |
224 | var view = this._create_view(view_name, output_area); |
|
220 | // element to cell's widget div. | |
225 | new_views.push(view); |
|
221 | var view = this._create_view(view_name, output_area); | |
226 | this._get_widget_area_element(output_area, true) |
|
222 | new_views.push(view); | |
227 | .append(view.$el); |
|
223 | this._get_widget_area_element(output_area, true) | |
228 |
|
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 |
|
252 | view.remove(); // Clean-up view | ||
231 | for (var view_index in new_views) { |
|
253 | if (that.views[output_area].length()==0) { | |
232 | var view = new_views[view_index]; |
|
254 | delete that.views[output_area]; | |
233 | view.update(); |
|
|||
234 | } |
|
255 | } | |
235 | }, |
|
|||
236 |
|
||||
237 |
|
256 | |||
238 | // Create a view |
|
257 | // Close the comm if there are no views left. | |
239 | _create_view: function (view_name, output_area) { |
|
258 | if (that.views.length()==0) { | |
240 | var view = new this.widget_view_types[view_name]({model: this}); |
|
259 | that.comm.close(); | |
241 | view.render(); |
|
|||
242 | if (this.views[output_area]==undefined) { |
|
|||
243 | this.views[output_area] = [] |
|
|||
244 | } |
|
260 | } | |
245 | this.views[output_area].push(view); |
|
261 | }); | |
246 | view.output_area = output_area; |
|
262 | return view; | |
247 |
|
263 | }, | ||
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 | }, |
|
|||
267 |
|
264 | |||
268 |
|
265 | |||
269 |
|
|
266 | // Build a callback dict. | |
270 |
|
|
267 | _make_callbacks: function (output_area) { | |
271 |
|
|
268 | var callbacks = {}; | |
272 |
|
|
269 | if (output_area != null) { | |
273 |
|
|
270 | var that = this; | |
274 |
|
|
271 | callbacks = { | |
275 |
|
|
272 | iopub : { | |
276 |
|
|
273 | output : $.proxy(output_area.handle_output, output_area), | |
277 |
|
|
274 | clear_output : $.proxy(output_area.handle_clear_output, output_area), | |
278 |
|
|
275 | status : function(msg){ | |
279 |
|
|
276 | that.handle_status(output_area, msg); | |
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 | }, |
|
|||
289 | }, |
|
277 | }, | |
290 | }; |
|
278 | get_output_area : function() { | |
291 | } |
|
279 | if (that.last_modified_view != undefined && | |
292 | return callbacks; |
|
280 | that.last_modified_view.output_area != undefined) { | |
293 | }, |
|
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 |
|
|
293 | // Get the output area corresponding to the msg_id. | |
297 |
|
|
294 | // output_area is an instance of Ipython.OutputArea | |
298 |
|
|
295 | _get_output_area: function (msg_id) { | |
299 |
|
|
296 | ||
300 |
|
|
297 | // First, guess cell.execute triggered | |
301 |
|
|
298 | var cells = IPython.notebook.get_cells(); | |
302 |
|
|
299 | for (var cell_index in cells) { | |
303 |
|
|
300 | if (cells[cell_index].last_msg_id == msg_id) { | |
304 |
|
|
301 | var cell = IPython.notebook.get_cell(cell_index) | |
305 |
|
|
302 | return cell.output_area; | |
306 | } |
|
|||
307 | } |
|
303 | } | |
|
304 | } | |||
308 |
|
305 | |||
309 |
|
|
306 | // Second, guess widget triggered | |
310 |
|
|
307 | var callbacks = this.comm_manager.kernel.get_callbacks_for_msg(msg_id) | |
311 |
|
|
308 | if (callbacks != undefined && callbacks.iopub != undefined && callbacks.iopub.get_output_area != undefined) { | |
312 |
|
|
309 | var output_area = callbacks.iopub.get_output_area(); | |
313 |
|
|
310 | if (output_area != null) { | |
314 |
|
|
311 | return output_area; | |
315 | } |
|
|||
316 | } |
|
312 | } | |
317 |
|
|
313 | } | |
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 | }, |
|
|||
347 |
|
314 | |||
348 | update: function() { |
|
315 | // Not triggered by a widget or a cell | |
349 | if (this.model.get('visible') != undefined) { |
|
316 | return null; | |
350 | if (this.visible != this.model.get('visible')) { |
|
317 | }, | |
351 | this.visible = this.model.get('visible'); |
|
318 | ||
352 | if (this.visible) { |
|
319 | // Gets widget output area (as a JQuery element) from the | |
353 | this.$el.show(); |
|
320 | // output_area (Ipython.OutputArea instance) | |
354 | } else { |
|
321 | _get_widget_area_element: function (output_area, show) { | |
355 | this.$el.hide(); |
|
322 | var widget_area = output_area.element | |
356 | } |
|
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 |
|
355 | } | ||
360 | if (this.model.css != undefined) { |
|
356 | ||
361 |
|
|
357 | if (this.model.css != undefined) { | |
362 |
|
|
358 | for (var selector in this.model.css) { | |
363 |
|
359 | if (this.model.css.hasOwnProperty(selector)) { | ||
364 | // Apply the css traits to all elements that match the selector. |
|
360 | ||
365 |
|
|
361 | // Apply the css traits to all elements that match the selector. | |
366 |
|
|
362 | var elements = this.get_selector_element(selector); | |
367 | var css_traits = this.model.css[selector]; |
|
363 | if (elements.length > 0) { | |
368 |
|
|
364 | var css_traits = this.model.css[selector]; | |
369 |
|
|
365 | for (var css_key in css_traits) { | |
370 |
|
|
366 | if (css_traits.hasOwnProperty(css_key)) { | |
371 |
|
|
367 | elements.css(css_key, css_traits[css_key]); | |
372 | } |
|
368 | } | |
373 | } |
|
369 | } | |
374 | } |
|
370 | } | |
375 | } |
|
371 | } | |
376 | } |
|
372 | } | |
377 |
|
373 | } | ||
378 | var add_class = this.model.get('_add_class'); |
|
374 | ||
379 | if (add_class != undefined){ |
|
375 | var add_class = this.model.get('_add_class'); | |
380 | var add_class_calls = add_class[0]; |
|
376 | if (add_class != undefined){ | |
381 |
|
|
377 | var add_class_calls = add_class[0]; | |
382 |
|
|
378 | if (add_class_calls > this._add_class_calls) { | |
383 | var elements = this.get_selector_element(add_class[1]); |
|
379 | this._add_class_calls = add_class_calls; | |
384 | if (elements.length > 0) { |
|
380 | var elements = this.get_selector_element(add_class[1]); | |
385 |
|
|
381 | if (elements.length > 0) { | |
386 | } |
|
382 | elements.addClass(add_class[2]); | |
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; |
|
|||
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; |
|
412 | } | |
417 | }, |
|
413 | return elements; | |
418 |
} |
|
414 | }, | |
419 |
|
415 | }); | ||
420 |
|
416 | |||
421 | //-------------------------------------------------------------------- |
|
417 | ||
422 | // WidgetManager class |
|
418 | //-------------------------------------------------------------------- | |
423 | //-------------------------------------------------------------------- |
|
419 | // WidgetManager class | |
424 | var WidgetManager = function(comm_manager){ |
|
420 | //-------------------------------------------------------------------- | |
425 | this.comm_manager = comm_manager; |
|
421 | var WidgetManager = function(){ | |
426 | this.widget_model_types = {}; |
|
422 | this.comm_manager = null; | |
427 |
|
|
423 | this.widget_model_types = {}; | |
428 |
|
424 | this.widget_view_types = {}; | ||
429 | var that = this; |
|
425 | ||
430 | Backbone.sync = function(method, model, options, error) { |
|
426 | var that = this; | |
431 | var result = model.handle_sync(method, options); |
|
427 | Backbone.sync = function(method, model, options, error) { | |
432 | if (options.success) { |
|
428 | var result = model.handle_sync(method, options); | |
433 |
|
|
429 | if (options.success) { | |
434 | } |
|
430 | options.success(result); | |
435 |
} |
|
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 |
|
|
446 | WidgetManager.prototype.register_widget_model = function (widget_model_name, widget_model_type) { | |
440 |
|
|
447 | // Register the widget with the comm manager. Make sure to pass this object's context | |
441 |
|
|
448 | // in so `this` works in the call back. | |
|
449 | if (this.comm_manager!=null) { | |||
442 | this.comm_manager.register_target(widget_model_name, $.proxy(this.handle_com_open, this)); |
|
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 |
|
|
456 | WidgetManager.prototype.register_widget_view = function (widget_view_name, widget_view_type) { | |
448 |
|
|
457 | this.widget_view_types[widget_view_name] = widget_view_type; | |
449 |
|
|
458 | } | |
450 |
|
459 | |||
451 |
|
460 | |||
452 |
|
|
461 | WidgetManager.prototype.handle_com_open = function (comm, msg) { | |
453 |
|
|
462 | var widget_type_name = msg.content.target_name; | |
454 |
|
|
463 | var widget_model = new this.widget_model_types[widget_type_name](this.comm_manager, comm, this.widget_view_types); | |
455 |
|
|
464 | } | |
456 |
|
465 | |||
457 |
|
466 | |||
458 |
|
|
467 | //-------------------------------------------------------------------- | |
459 |
|
|
468 | // Init code | |
460 |
|
|
469 | //-------------------------------------------------------------------- | |
461 |
|
|
470 | IPython.WidgetManager = WidgetManager; | |
462 |
|
|
471 | IPython.WidgetModel = WidgetModel; | |
463 |
|
|
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 | var BoolWidgetModel = IPython.WidgetModel.extend({}); |
|
4 | var BoolWidgetModel = IPython.WidgetModel.extend({}); | |
5 |
IPython |
|
5 | IPython.widget_manager.register_widget_model('BoolWidgetModel', BoolWidgetModel); | |
6 |
|
6 | |||
7 | var CheckboxView = IPython.WidgetView.extend({ |
|
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 | var ToggleButtonView = IPython.WidgetView.extend({ |
|
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 | var ButtonWidgetModel = IPython.WidgetModel.extend({}); |
|
4 | var ButtonWidgetModel = IPython.WidgetModel.extend({}); | |
5 |
IPython |
|
5 | IPython.widget_manager.register_widget_model('ButtonWidgetModel', ButtonWidgetModel); | |
6 |
|
6 | |||
7 | var ButtonView = IPython.WidgetView.extend({ |
|
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 | var ContainerModel = IPython.WidgetModel.extend({}); |
|
2 | var ContainerModel = IPython.WidgetModel.extend({}); | |
3 |
IPython |
|
3 | IPython.widget_manager.register_widget_model('ContainerWidgetModel', ContainerModel); | |
4 |
|
4 | |||
5 | var ContainerView = IPython.WidgetView.extend({ |
|
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 | }); No newline at end of file |
|
46 | }); |
@@ -1,4 +1,4 b'' | |||||
1 |
|
|
1 | define(["notebook/js/widget"], function(){ | |
2 | var FloatWidgetModel = IPython.WidgetModel.extend({}); |
|
2 | var FloatWidgetModel = IPython.WidgetModel.extend({}); | |
3 |
IPython |
|
3 | IPython.widget_manager.register_widget_model('FloatWidgetModel', FloatWidgetModel); | |
4 | }); No newline at end of file |
|
4 | }); |
@@ -1,6 +1,6 b'' | |||||
1 |
|
|
1 | define(["notebook/js/widget"], function(){ | |
2 | var FloatRangeWidgetModel = IPython.WidgetModel.extend({}); |
|
2 | var FloatRangeWidgetModel = IPython.WidgetModel.extend({}); | |
3 |
IPython |
|
3 | IPython.widget_manager.register_widget_model('FloatRangeWidgetModel', FloatRangeWidgetModel); | |
4 |
|
4 | |||
5 | var FloatSliderView = IPython.WidgetView.extend({ |
|
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 | var FloatTextView = IPython.WidgetView.extend({ |
|
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 | var ProgressView = IPython.WidgetView.extend({ |
|
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 | var IntWidgetModel = IPython.WidgetModel.extend({}); |
|
2 | var IntWidgetModel = IPython.WidgetModel.extend({}); | |
3 |
IPython |
|
3 | IPython.widget_manager.register_widget_model('IntWidgetModel', IntWidgetModel); | |
4 | }); No newline at end of file |
|
4 | }); |
@@ -1,6 +1,6 b'' | |||||
1 |
|
|
1 | define(["notebook/js/widget"], function(){ | |
2 | var IntRangeWidgetModel = IPython.WidgetModel.extend({}); |
|
2 | var IntRangeWidgetModel = IPython.WidgetModel.extend({}); | |
3 |
IPython |
|
3 | IPython.widget_manager.register_widget_model('IntRangeWidgetModel', IntRangeWidgetModel); | |
4 |
|
4 | |||
5 | var IntSliderView = IPython.WidgetView.extend({ |
|
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 | var IntTextView = IPython.WidgetView.extend({ |
|
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 | var MulticontainerModel = IPython.WidgetModel.extend({}); |
|
2 | var MulticontainerModel = IPython.WidgetModel.extend({}); | |
3 |
IPython |
|
3 | IPython.widget_manager.register_widget_model('MulticontainerWidgetModel', MulticontainerModel); | |
4 |
|
4 | |||
5 | var AccordionView = IPython.WidgetView.extend({ |
|
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 | var TabView = IPython.WidgetView.extend({ |
|
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 | var SelectionWidgetModel = IPython.WidgetModel.extend({}); |
|
2 | var SelectionWidgetModel = IPython.WidgetModel.extend({}); | |
3 |
IPython |
|
3 | IPython.widget_manager.register_widget_model('SelectionWidgetModel', SelectionWidgetModel); | |
4 |
|
4 | |||
5 | var DropdownView = IPython.WidgetView.extend({ |
|
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 | var RadioButtonsView = IPython.WidgetView.extend({ |
|
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 | var ToggleButtonsView = IPython.WidgetView.extend({ |
|
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 | var StringWidgetModel = IPython.WidgetModel.extend({}); |
|
2 | var StringWidgetModel = IPython.WidgetModel.extend({}); | |
3 |
IPython |
|
3 | IPython.widget_manager.register_widget_model('StringWidgetModel', StringWidgetModel); | |
4 |
|
4 | |||
5 | var LabelView = IPython.WidgetView.extend({ |
|
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 | var TextAreaView = IPython.WidgetView.extend({ |
|
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 | var TextBoxView = IPython.WidgetView.extend({ |
|
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 | from .widget_bool import BoolWidget |
|
3 | from .widget_bool import BoolWidget | |
4 | from .widget_button import ButtonWidget |
|
4 | from .widget_button import ButtonWidget |
@@ -26,19 +26,6 b' from IPython.utils.traitlets import Unicode, Dict, List, Instance, Bool' | |||||
26 | from IPython.display import Javascript, display |
|
26 | from IPython.display import Javascript, display | |
27 | from IPython.utils.py3compat import string_types |
|
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 | # Classes |
|
31 | # Classes |
@@ -18,85 +18,11 b'' | |||||
18 | "collapsed": false, |
|
18 | "collapsed": false, | |
19 | "input": [ |
|
19 | "input": [ | |
20 | "from IPython.html import widgets # Widget definitions\n", |
|
20 | "from IPython.html import widgets # Widget definitions\n", | |
21 |
"from IPython.display import display # Used to display widgets in the notebook |
|
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()" |
|
|||
25 | ], |
|
22 | ], | |
26 | "language": "python", |
|
23 | "language": "python", | |
27 | "metadata": {}, |
|
24 | "metadata": {}, | |
28 | "outputs": [ |
|
25 | "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 | ], |
|
|||
100 | "prompt_number": 1 |
|
26 | "prompt_number": 1 | |
101 | }, |
|
27 | }, | |
102 | { |
|
28 | { | |
@@ -141,7 +67,7 b'' | |||||
141 | " \n", |
|
67 | " \n", | |
142 | " // Define the FileModel and register it with the widget manager.\n", |
|
68 | " // Define the FileModel and register it with the widget manager.\n", | |
143 | " var FileModel = IPython.WidgetModel.extend({});\n", |
|
69 | " var FileModel = IPython.WidgetModel.extend({});\n", | |
144 |
" IPython. |
|
70 | " IPython.widget_manager.register_widget_model('FileWidgetModel', FileModel);\n", | |
145 | " \n", |
|
71 | " \n", | |
146 | " // Define the FilePickerView\n", |
|
72 | " // Define the FilePickerView\n", | |
147 | " var FilePickerView = IPython.WidgetView.extend({\n", |
|
73 | " var FilePickerView = IPython.WidgetView.extend({\n", | |
@@ -176,7 +102,7 b'' | |||||
176 | " });\n", |
|
102 | " });\n", | |
177 | " \n", |
|
103 | " \n", | |
178 | " // Register the DatePickerView with the widget manager.\n", |
|
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 | "language": "python", |
|
108 | "language": "python", | |
@@ -189,7 +115,7 b'' | |||||
189 | " \n", |
|
115 | " \n", | |
190 | " // Define the FileModel and register it with the widget manager.\n", |
|
116 | " // Define the FileModel and register it with the widget manager.\n", | |
191 | " var FileModel = IPython.WidgetModel.extend({});\n", |
|
117 | " var FileModel = IPython.WidgetModel.extend({});\n", | |
192 |
" IPython. |
|
118 | " IPython.widget_manager.register_widget_model('FileWidgetModel', FileModel);\n", | |
193 | " \n", |
|
119 | " \n", | |
194 | " // Define the FilePickerView\n", |
|
120 | " // Define the FilePickerView\n", | |
195 | " var FilePickerView = IPython.WidgetView.extend({\n", |
|
121 | " var FilePickerView = IPython.WidgetView.extend({\n", | |
@@ -202,7 +128,6 b'' | |||||
202 | " },\n", |
|
128 | " },\n", | |
203 | " \n", |
|
129 | " \n", | |
204 | " // Handles: User input\n", |
|
130 | " // Handles: User input\n", | |
205 | " events: { \"change\" : \"handleFileChange\" }, \n", |
|
|||
206 | " handleFileChange: function(evt) { \n", |
|
131 | " handleFileChange: function(evt) { \n", | |
207 | " \n", |
|
132 | " \n", | |
208 | " //Retrieve the first (and only!) File from the FileList object\n", |
|
133 | " //Retrieve the first (and only!) File from the FileList object\n", | |
@@ -225,13 +150,13 b'' | |||||
225 | " });\n", |
|
150 | " });\n", | |
226 | " \n", |
|
151 | " \n", | |
227 | " // Register the DatePickerView with the widget manager.\n", |
|
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 | "metadata": {}, |
|
156 | "metadata": {}, | |
232 | "output_type": "display_data", |
|
157 | "output_type": "display_data", | |
233 | "text": [ |
|
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 | "metadata": { |
|
2 | "metadata": { | |
|
3 | "cell_tags": [ | |||
|
4 | [ | |||
|
5 | "<None>", | |||
|
6 | null | |||
|
7 | ] | |||
|
8 | ], | |||
3 | "name": "" |
|
9 | "name": "" | |
4 | }, |
|
10 | }, | |
5 | "nbformat": 3, |
|
11 | "nbformat": 3, | |
@@ -11,7 +17,7 b'' | |||||
11 | "cell_type": "markdown", |
|
17 | "cell_type": "markdown", | |
12 | "metadata": {}, |
|
18 | "metadata": {}, | |
13 | "source": [ |
|
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 | "collapsed": false, |
|
25 | "collapsed": false, | |
20 | "input": [ |
|
26 | "input": [ | |
21 | "from IPython.html import widgets # Widget definitions\n", |
|
27 | "from IPython.html import widgets # Widget definitions\n", | |
22 |
"from IPython.display import display # Used to display widgets in the notebook |
|
28 | "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()" |
|
|||
26 | ], |
|
29 | ], | |
27 | "language": "python", |
|
30 | "language": "python", | |
28 | "metadata": {}, |
|
31 | "metadata": {}, | |
29 | "outputs": [ |
|
32 | "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 | ], |
|
|||
101 | "prompt_number": 1 |
|
33 | "prompt_number": 1 | |
102 | }, |
|
34 | }, | |
103 | { |
|
35 | { |
@@ -1,5 +1,11 b'' | |||||
1 | { |
|
1 | { | |
2 | "metadata": { |
|
2 | "metadata": { | |
|
3 | "cell_tags": [ | |||
|
4 | [ | |||
|
5 | "<None>", | |||
|
6 | null | |||
|
7 | ] | |||
|
8 | ], | |||
3 | "name": "" |
|
9 | "name": "" | |
4 | }, |
|
10 | }, | |
5 | "nbformat": 3, |
|
11 | "nbformat": 3, | |
@@ -12,85 +18,11 b'' | |||||
12 | "collapsed": false, |
|
18 | "collapsed": false, | |
13 | "input": [ |
|
19 | "input": [ | |
14 | "from IPython.html import widgets # Widget definitions\n", |
|
20 | "from IPython.html import widgets # Widget definitions\n", | |
15 |
"from IPython.display import display # Used to display widgets in the notebook |
|
21 | "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()" |
|
|||
19 | ], |
|
22 | ], | |
20 | "language": "python", |
|
23 | "language": "python", | |
21 | "metadata": {}, |
|
24 | "metadata": {}, | |
22 | "outputs": [ |
|
25 | "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 | ], |
|
|||
94 | "prompt_number": 1 |
|
26 | "prompt_number": 1 | |
95 | }, |
|
27 | }, | |
96 | { |
|
28 | { |
@@ -1,5 +1,11 b'' | |||||
1 | { |
|
1 | { | |
2 | "metadata": { |
|
2 | "metadata": { | |
|
3 | "cell_tags": [ | |||
|
4 | [ | |||
|
5 | "<None>", | |||
|
6 | null | |||
|
7 | ] | |||
|
8 | ], | |||
3 | "name": "" |
|
9 | "name": "" | |
4 | }, |
|
10 | }, | |
5 | "nbformat": 3, |
|
11 | "nbformat": 3, | |
@@ -12,85 +18,11 b'' | |||||
12 | "collapsed": false, |
|
18 | "collapsed": false, | |
13 | "input": [ |
|
19 | "input": [ | |
14 | "from IPython.html import widgets # Widget definitions\n", |
|
20 | "from IPython.html import widgets # Widget definitions\n", | |
15 |
"from IPython.display import display # Used to display widgets in the notebook |
|
21 | "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()" |
|
|||
19 | ], |
|
22 | ], | |
20 | "language": "python", |
|
23 | "language": "python", | |
21 | "metadata": {}, |
|
24 | "metadata": {}, | |
22 | "outputs": [ |
|
25 | "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 | ], |
|
|||
94 | "prompt_number": 1 |
|
26 | "prompt_number": 1 | |
95 | }, |
|
27 | }, | |
96 | { |
|
28 | { |
@@ -1,5 +1,11 b'' | |||||
1 | { |
|
1 | { | |
2 | "metadata": { |
|
2 | "metadata": { | |
|
3 | "cell_tags": [ | |||
|
4 | [ | |||
|
5 | "<None>", | |||
|
6 | null | |||
|
7 | ] | |||
|
8 | ], | |||
3 | "name": "" |
|
9 | "name": "" | |
4 | }, |
|
10 | }, | |
5 | "nbformat": 3, |
|
11 | "nbformat": 3, | |
@@ -12,85 +18,11 b'' | |||||
12 | "collapsed": false, |
|
18 | "collapsed": false, | |
13 | "input": [ |
|
19 | "input": [ | |
14 | "from IPython.html import widgets # Widget definitions\n", |
|
20 | "from IPython.html import widgets # Widget definitions\n", | |
15 |
"from IPython.display import display # Used to display widgets in the notebook |
|
21 | "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()" |
|
|||
19 | ], |
|
22 | ], | |
20 | "language": "python", |
|
23 | "language": "python", | |
21 | "metadata": {}, |
|
24 | "metadata": {}, | |
22 | "outputs": [ |
|
25 | "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 | ], |
|
|||
94 | "prompt_number": 1 |
|
26 | "prompt_number": 1 | |
95 | }, |
|
27 | }, | |
96 | { |
|
28 | { |
@@ -18,85 +18,11 b'' | |||||
18 | "collapsed": false, |
|
18 | "collapsed": false, | |
19 | "input": [ |
|
19 | "input": [ | |
20 | "from IPython.html import widgets # Widget definitions\n", |
|
20 | "from IPython.html import widgets # Widget definitions\n", | |
21 |
"from IPython.display import display # Used to display widgets in the notebook |
|
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()" |
|
|||
25 | ], |
|
22 | ], | |
26 | "language": "python", |
|
23 | "language": "python", | |
27 | "metadata": {}, |
|
24 | "metadata": {}, | |
28 | "outputs": [ |
|
25 | "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 | ], |
|
|||
100 | "prompt_number": 1 |
|
26 | "prompt_number": 1 | |
101 | }, |
|
27 | }, | |
102 | { |
|
28 | { |
@@ -30,85 +30,11 b'' | |||||
30 | "collapsed": false, |
|
30 | "collapsed": false, | |
31 | "input": [ |
|
31 | "input": [ | |
32 | "from IPython.html import widgets # Widget definitions\n", |
|
32 | "from IPython.html import widgets # Widget definitions\n", | |
33 |
"from IPython.display import display # Used to display widgets in the notebook |
|
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()" |
|
|||
37 | ], |
|
34 | ], | |
38 | "language": "python", |
|
35 | "language": "python", | |
39 | "metadata": {}, |
|
36 | "metadata": {}, | |
40 | "outputs": [ |
|
37 | "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 | ], |
|
|||
112 | "prompt_number": 1 |
|
38 | "prompt_number": 1 | |
113 | }, |
|
39 | }, | |
114 | { |
|
40 | { | |
@@ -213,7 +139,7 b'' | |||||
213 | "metadata": {}, |
|
139 | "metadata": {}, | |
214 | "output_type": "display_data", |
|
140 | "output_type": "display_data", | |
215 | "text": [ |
|
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 | " \n", |
|
162 | " \n", | |
237 | " // Define the DateModel and register it with the widget manager.\n", |
|
163 | " // Define the DateModel and register it with the widget manager.\n", | |
238 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
164 | " var DateModel = IPython.WidgetModel.extend({});\n", | |
239 |
" IPython. |
|
165 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
240 | "});" |
|
166 | "});" | |
241 | ], |
|
167 | ], | |
242 | "language": "python", |
|
168 | "language": "python", | |
@@ -249,13 +175,13 b'' | |||||
249 | " \n", |
|
175 | " \n", | |
250 | " // Define the DateModel and register it with the widget manager.\n", |
|
176 | " // Define the DateModel and register it with the widget manager.\n", | |
251 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
177 | " var DateModel = IPython.WidgetModel.extend({});\n", | |
252 |
" IPython. |
|
178 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
253 | "});" |
|
179 | "});" | |
254 | ], |
|
180 | ], | |
255 | "metadata": {}, |
|
181 | "metadata": {}, | |
256 | "output_type": "display_data", |
|
182 | "output_type": "display_data", | |
257 | "text": [ |
|
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 | " \n", |
|
206 | " \n", | |
281 | " // Define the DateModel and register it with the widget manager.\n", |
|
207 | " // Define the DateModel and register it with the widget manager.\n", | |
282 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
208 | " var DateModel = IPython.WidgetModel.extend({});\n", | |
283 |
" IPython. |
|
209 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
284 | " \n", |
|
210 | " \n", | |
285 | " // Define the DatePickerView\n", |
|
211 | " // Define the DatePickerView\n", | |
286 | " var DatePickerView = IPython.WidgetView.extend({\n", |
|
212 | " var DatePickerView = IPython.WidgetView.extend({\n", | |
@@ -292,7 +218,7 b'' | |||||
292 | " });\n", |
|
218 | " });\n", | |
293 | " \n", |
|
219 | " \n", | |
294 | " // Register the DatePickerView with the widget manager.\n", |
|
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 | "language": "python", |
|
224 | "language": "python", | |
@@ -305,7 +231,7 b'' | |||||
305 | " \n", |
|
231 | " \n", | |
306 | " // Define the DateModel and register it with the widget manager.\n", |
|
232 | " // Define the DateModel and register it with the widget manager.\n", | |
307 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
233 | " var DateModel = IPython.WidgetModel.extend({});\n", | |
308 |
" IPython. |
|
234 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
309 | " \n", |
|
235 | " \n", | |
310 | " // Define the DatePickerView\n", |
|
236 | " // Define the DatePickerView\n", | |
311 | " var DatePickerView = IPython.WidgetView.extend({\n", |
|
237 | " var DatePickerView = IPython.WidgetView.extend({\n", | |
@@ -317,13 +243,13 b'' | |||||
317 | " });\n", |
|
243 | " });\n", | |
318 | " \n", |
|
244 | " \n", | |
319 | " // Register the DatePickerView with the widget manager.\n", |
|
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 | "metadata": {}, |
|
249 | "metadata": {}, | |
324 | "output_type": "display_data", |
|
250 | "output_type": "display_data", | |
325 | "text": [ |
|
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 | " \n", |
|
352 | " \n", | |
427 | " // Define the DateModel and register it with the widget manager.\n", |
|
353 | " // Define the DateModel and register it with the widget manager.\n", | |
428 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
354 | " var DateModel = IPython.WidgetModel.extend({});\n", | |
429 |
" IPython. |
|
355 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
430 | " \n", |
|
356 | " \n", | |
431 | " // Define the DatePickerView\n", |
|
357 | " // Define the DatePickerView\n", | |
432 | " var DatePickerView = IPython.WidgetView.extend({\n", |
|
358 | " var DatePickerView = IPython.WidgetView.extend({\n", | |
@@ -443,7 +369,7 b'' | |||||
443 | " });\n", |
|
369 | " });\n", | |
444 | " \n", |
|
370 | " \n", | |
445 | " // Register the DatePickerView with the widget manager.\n", |
|
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 | "language": "python", |
|
375 | "language": "python", | |
@@ -456,7 +382,7 b'' | |||||
456 | " \n", |
|
382 | " \n", | |
457 | " // Define the DateModel and register it with the widget manager.\n", |
|
383 | " // Define the DateModel and register it with the widget manager.\n", | |
458 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
384 | " var DateModel = IPython.WidgetModel.extend({});\n", | |
459 |
" IPython. |
|
385 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
460 | " \n", |
|
386 | " \n", | |
461 | " // Define the DatePickerView\n", |
|
387 | " // Define the DatePickerView\n", | |
462 | " var DatePickerView = IPython.WidgetView.extend({\n", |
|
388 | " var DatePickerView = IPython.WidgetView.extend({\n", | |
@@ -473,13 +399,13 b'' | |||||
473 | " });\n", |
|
399 | " });\n", | |
474 | " \n", |
|
400 | " \n", | |
475 | " // Register the DatePickerView with the widget manager.\n", |
|
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 | "metadata": {}, |
|
405 | "metadata": {}, | |
480 | "output_type": "display_data", |
|
406 | "output_type": "display_data", | |
481 | "text": [ |
|
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 | " \n", |
|
428 | " \n", | |
503 | " // Define the DateModel and register it with the widget manager.\n", |
|
429 | " // Define the DateModel and register it with the widget manager.\n", | |
504 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
430 | " var DateModel = IPython.WidgetModel.extend({});\n", | |
505 |
" IPython. |
|
431 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
506 | " \n", |
|
432 | " \n", | |
507 | " // Define the DatePickerView\n", |
|
433 | " // Define the DatePickerView\n", | |
508 | " var DatePickerView = IPython.WidgetView.extend({\n", |
|
434 | " var DatePickerView = IPython.WidgetView.extend({\n", | |
@@ -526,7 +452,7 b'' | |||||
526 | " });\n", |
|
452 | " });\n", | |
527 | " \n", |
|
453 | " \n", | |
528 | " // Register the DatePickerView with the widget manager.\n", |
|
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 | "language": "python", |
|
458 | "language": "python", | |
@@ -539,7 +465,7 b'' | |||||
539 | " \n", |
|
465 | " \n", | |
540 | " // Define the DateModel and register it with the widget manager.\n", |
|
466 | " // Define the DateModel and register it with the widget manager.\n", | |
541 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
467 | " var DateModel = IPython.WidgetModel.extend({});\n", | |
542 |
" IPython. |
|
468 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
543 | " \n", |
|
469 | " \n", | |
544 | " // Define the DatePickerView\n", |
|
470 | " // Define the DatePickerView\n", | |
545 | " var DatePickerView = IPython.WidgetView.extend({\n", |
|
471 | " var DatePickerView = IPython.WidgetView.extend({\n", | |
@@ -563,13 +489,13 b'' | |||||
563 | " });\n", |
|
489 | " });\n", | |
564 | " \n", |
|
490 | " \n", | |
565 | " // Register the DatePickerView with the widget manager.\n", |
|
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 | "metadata": {}, |
|
495 | "metadata": {}, | |
570 | "output_type": "display_data", |
|
496 | "output_type": "display_data", | |
571 | "text": [ |
|
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 | " \n", |
|
522 | " \n", | |
597 | " // Define the DateModel and register it with the widget manager.\n", |
|
523 | " // Define the DateModel and register it with the widget manager.\n", | |
598 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
524 | " var DateModel = IPython.WidgetModel.extend({});\n", | |
599 |
" IPython. |
|
525 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
600 | " \n", |
|
526 | " \n", | |
601 | " // Define the DatePickerView\n", |
|
527 | " // Define the DatePickerView\n", | |
602 | " var DatePickerView = IPython.WidgetView.extend({\n", |
|
528 | " var DatePickerView = IPython.WidgetView.extend({\n", | |
@@ -632,7 +558,7 b'' | |||||
632 | " });\n", |
|
558 | " });\n", | |
633 | " \n", |
|
559 | " \n", | |
634 | " // Register the DatePickerView with the widget manager.\n", |
|
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 | "language": "python", |
|
564 | "language": "python", | |
@@ -645,7 +571,7 b'' | |||||
645 | " \n", |
|
571 | " \n", | |
646 | " // Define the DateModel and register it with the widget manager.\n", |
|
572 | " // Define the DateModel and register it with the widget manager.\n", | |
647 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
573 | " var DateModel = IPython.WidgetModel.extend({});\n", | |
648 |
" IPython. |
|
574 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
649 | " \n", |
|
575 | " \n", | |
650 | " // Define the DatePickerView\n", |
|
576 | " // Define the DatePickerView\n", | |
651 | " var DatePickerView = IPython.WidgetView.extend({\n", |
|
577 | " var DatePickerView = IPython.WidgetView.extend({\n", | |
@@ -681,13 +607,13 b'' | |||||
681 | " });\n", |
|
607 | " });\n", | |
682 | " \n", |
|
608 | " \n", | |
683 | " // Register the DatePickerView with the widget manager.\n", |
|
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 | "metadata": {}, |
|
613 | "metadata": {}, | |
688 | "output_type": "display_data", |
|
614 | "output_type": "display_data", | |
689 | "text": [ |
|
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 | "output_type": "pyout", |
|
685 | "output_type": "pyout", | |
760 | "prompt_number": 13, |
|
686 | "prompt_number": 13, | |
761 | "text": [ |
|
687 | "text": [ | |
762 | "u''" |
|
688 | "u'2013-11-14'" | |
763 | ] |
|
689 | ] | |
764 | } |
|
690 | } | |
765 | ], |
|
691 | ], | |
@@ -1041,7 +967,7 b'' | |||||
1041 | " \n", |
|
967 | " \n", | |
1042 | " // Define the DateModel and register it with the widget manager.\n", |
|
968 | " // Define the DateModel and register it with the widget manager.\n", | |
1043 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
969 | " var DateModel = IPython.WidgetModel.extend({});\n", | |
1044 |
" IPython. |
|
970 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
1045 | " \n", |
|
971 | " \n", | |
1046 | " // Define the DatePickerView\n", |
|
972 | " // Define the DatePickerView\n", | |
1047 | " var DatePickerView = IPython.WidgetView.extend({\n", |
|
973 | " var DatePickerView = IPython.WidgetView.extend({\n", | |
@@ -1095,7 +1021,7 b'' | |||||
1095 | " });\n", |
|
1021 | " });\n", | |
1096 | " \n", |
|
1022 | " \n", | |
1097 | " // Register the DatePickerView with the widget manager.\n", |
|
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 | "language": "python", |
|
1027 | "language": "python", | |
@@ -1108,7 +1034,7 b'' | |||||
1108 | " \n", |
|
1034 | " \n", | |
1109 | " // Define the DateModel and register it with the widget manager.\n", |
|
1035 | " // Define the DateModel and register it with the widget manager.\n", | |
1110 | " var DateModel = IPython.WidgetModel.extend({});\n", |
|
1036 | " var DateModel = IPython.WidgetModel.extend({});\n", | |
1111 |
" IPython. |
|
1037 | " IPython.widget_manager.register_widget_model('DateWidgetModel', DateModel);\n", | |
1112 | " \n", |
|
1038 | " \n", | |
1113 | " // Define the DatePickerView\n", |
|
1039 | " // Define the DatePickerView\n", | |
1114 | " var DatePickerView = IPython.WidgetView.extend({\n", |
|
1040 | " var DatePickerView = IPython.WidgetView.extend({\n", | |
@@ -1162,13 +1088,13 b'' | |||||
1162 | " });\n", |
|
1088 | " });\n", | |
1163 | " \n", |
|
1089 | " \n", | |
1164 | " // Register the DatePickerView with the widget manager.\n", |
|
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 | "metadata": {}, |
|
1094 | "metadata": {}, | |
1169 | "output_type": "display_data", |
|
1095 | "output_type": "display_data", | |
1170 | "text": [ |
|
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 | "cell_type": "code", |
|
1142 | "cell_type": "code", | |
1217 | "collapsed": false, |
|
1143 | "collapsed": false, | |
1218 | "input": [ |
|
1144 | "input": [ | |
1219 | "\n", |
|
|||
1220 | "display(my_widget, view_name=\"TextBoxView\")" |
|
1145 | "display(my_widget, view_name=\"TextBoxView\")" | |
1221 | ], |
|
1146 | ], | |
1222 | "language": "python", |
|
1147 | "language": "python", |
General Comments 0
You need to be logged in to leave comments.
Login now