Show More
@@ -193,7 +193,7 define([ | |||
|
193 | 193 | WidgetManager.prototype.create_model = function (options) { |
|
194 | 194 | // Create and return a new widget model. |
|
195 | 195 | // |
|
196 |
// Minimally, one must provide the model_name and |
|
|
196 | // Minimally, one must provide the model_name and widget_class | |
|
197 | 197 | // parameters to create a model from Javascript. |
|
198 | 198 | // |
|
199 | 199 | // Example |
@@ -201,7 +201,7 define([ | |||
|
201 | 201 | // JS: |
|
202 | 202 | // window.slider = IPython.notebook.kernel.widget_manager.create_model({ |
|
203 | 203 | // model_name: 'WidgetModel', |
|
204 |
// |
|
|
204 | // widget_class: 'IPython.html.widgets.widget_int.IntSlider', | |
|
205 | 205 | // init_state_callback: function(model) { console.log('Create success!', model); }}); |
|
206 | 206 | // |
|
207 | 207 | // Parameters |
@@ -210,7 +210,7 define([ | |||
|
210 | 210 | // Dictionary of options with the following contents: |
|
211 | 211 | // model_name: string |
|
212 | 212 | // Target name of the widget model to create. |
|
213 |
// |
|
|
213 | // widget_class: (optional) string | |
|
214 | 214 | // Target name of the widget in the back-end. |
|
215 | 215 | // comm: (optional) Comm |
|
216 | 216 | // init_state_callback: (optional) callback |
@@ -221,7 +221,7 define([ | |||
|
221 | 221 | // Create a comm if it wasn't provided. |
|
222 | 222 | var comm = options.comm; |
|
223 | 223 | if (!comm) { |
|
224 |
comm = this.comm_manager.new_comm('ipython.widget', {' |
|
|
224 | comm = this.comm_manager.new_comm('ipython.widget', {'widget_class': options.widget_class}); | |
|
225 | 225 | } |
|
226 | 226 | |
|
227 | 227 | // Create and return a new model that is connected to the comm. |
@@ -99,8 +99,7 class Widget(LoggingConfigurable): | |||
|
99 | 99 | @staticmethod |
|
100 | 100 | def handle_comm_opened(comm, msg): |
|
101 | 101 | """Static method, called when a widget is constructed.""" |
|
102 |
|
|
|
103 | widget_class = import_item(target_name) | |
|
102 | widget_class = import_item(msg['content']['data']['widget_class']) | |
|
104 | 103 | widget = widget_class(comm=comm) |
|
105 | 104 | |
|
106 | 105 |
General Comments 0
You need to be logged in to leave comments.
Login now