Show More
@@ -28,6 +28,19 b' DirectViewWidget.prototype.create_element = function () {' | |||
|
28 | 28 | this.element.addClass('cell border-box-sizing code_cell vbox'); |
|
29 | 29 | this.element.attr('tabindex','2'); |
|
30 | 30 | this.element.css('padding-right',0); |
|
31 | ||
|
32 | var control = $('<div/>').addClass('dv_control').height('30px'); | |
|
33 | var control_label = $('<span/>').html('Select engine(s) to run code on interactively: '); | |
|
34 | control_label.css('line-height','30px'); | |
|
35 | var select = $('<select/>').addClass('dv_select ui-widget ui-widget-content'); | |
|
36 | select.css('font-size','85%%').css('margin-bottom','5px'); | |
|
37 | var n = this.targets.length; | |
|
38 | select.append($('<option/>').html('all').attr('value','all')); | |
|
39 | for (var i=0; i<n; i++) { | |
|
40 | select.append($('<option/>').html(this.targets[i]).attr('value',this.targets[i])) | |
|
41 | } | |
|
42 | control.append(control_label).append(select); | |
|
43 | ||
|
31 | 44 | var input = $('<div></div>').addClass('input hbox'); |
|
32 | 45 | var input_area = $('<div/>').addClass('input_area box-flex1'); |
|
33 | 46 | this.code_mirror = CodeMirror(input_area.get(0), { |
@@ -38,7 +51,9 b' DirectViewWidget.prototype.create_element = function () {' | |||
|
38 | 51 | }); |
|
39 | 52 | input.append(input_area); |
|
40 | 53 | var output = $('<div></div>'); |
|
41 | this.element.append(input).append(output); | |
|
54 | ||
|
55 | ||
|
56 | this.element.append(control).append(input).append(output); | |
|
42 | 57 | this.output_area = new IPython.OutputArea(output, false); |
|
43 | 58 | |
|
44 | 59 | }; |
@@ -100,7 +115,11 b' DirectViewWidget.prototype.execute = function () {' | |||
|
100 | 115 | 'output': $.proxy(this.output_area.handle_output, this.output_area), |
|
101 | 116 | 'clear_output': $.proxy(this.output_area.handle_clear_output, this.output_area), |
|
102 | 117 | }; |
|
103 | var code = '%(widget_var)s.execute("""'+this.get_text()+'""")'; | |
|
118 | var target = this.element.find('.dv_select option:selected').attr('value'); | |
|
119 | if (target === 'all') { | |
|
120 | target = '"all"'; | |
|
121 | } | |
|
122 | var code = '%(widget_var)s.execute("""'+this.get_text()+'""",targets='+target+')'; | |
|
104 | 123 | console.log(code); |
|
105 | 124 | console.log(this.get_text()); |
|
106 | 125 | var msg_id = this.kernel.execute(code, callbacks, {silent: false}); |
@@ -50,11 +50,19 b' class DirectViewWidget(JavascriptWidget):' | |||
|
50 | 50 | jscode = jscode % data |
|
51 | 51 | return jscode |
|
52 | 52 | |
|
53 | def execute(self,code): | |
|
54 | ar = self.dv.execute(code,block=False,targets='all') | |
|
53 | def execute(self, code, targets='all'): | |
|
54 | if targets == 'all': | |
|
55 | targets = self.targets | |
|
56 | ar = self.dv.execute(code,block=False,targets=targets) | |
|
55 | 57 | ar.wait() |
|
56 | 58 | metadata = ar.metadata |
|
59 | if isinstance(metadata, (list,tuple)): | |
|
57 | 60 | for md in metadata: |
|
61 | self.publish_md(md) | |
|
62 | elif isinstance(metadata, dict): | |
|
63 | self.publish_md(metadata) | |
|
64 | ||
|
65 | def publish_md(self, md): | |
|
58 | 66 |
|
|
59 | 67 |
|
|
60 | 68 |
|
@@ -63,7 +71,6 b' class DirectViewWidget(JavascriptWidget):' | |||
|
63 | 71 |
|
|
64 | 72 | |
|
65 | 73 | |
|
66 | ||
|
67 | 74 | def interact(dv): |
|
68 | 75 | w = DirectViewWidget(dv) |
|
69 | 76 | w.interact() |
General Comments 0
You need to be logged in to leave comments.
Login now