-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython-shell.html
More file actions
78 lines (78 loc) · 3.04 KB
/
python-shell.html
File metadata and controls
78 lines (78 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<script type="text/x-red" data-template-name="python-shell">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> 名前</label>
<input type="text" id="node-input-name">
</div>
<div class="form-row" style="margin-bottom: 0px;">
<label for="node-input-python"><i class="fa fa-wrench"></i> コード</label>
<input type="hidden" id="node-input-python" autofocus="autofocus">
</div>
<div class="form-row node-text-editor-row">
<div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-input-python-editor" ></div>
</div>
<div class="form-row">
<label for="node-input-pypath"><i class="fa fa-tag"></i> pythonパス</label>
<input type="text" id="node-input-pypath">
</div>
<div class="form-row">
<label for="node-input-pyshellpath"><i class="fa fa-tag"></i> python-shellパス</label>
<input type="text" id="node-input-pyshellpath">
</div>
</script>
<script type="text/x-red" data-help-name="python-shell">
<p>python shell</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('python-shell',{
color:"#4682b4",
category: 'python',
defaults: {
name: {value:""},
python: {value:"\nprint('hoge')"},
pypath: {value:"python"},
pyshellpath: {value:"./python-shell"}
},
inputs:1,
outputs:1,
icon: "python.png",
label: function() {
return this.name;
},
oneditprepare: function() {
var that = this;
this.editor = RED.editor.createEditor({
id: 'node-input-python-editor',
mode: 'ace/mode/none',
value: $("#node-input-python").val()
});
RED.library.create({
url:"functions", // where to get the data from
type:"function", // the type of object the library is for
editor:this.editor, // the field name the main text body goes to
fields:['name','outputs']
});
this.editor.focus();
},
oneditsave: function() {
var annot = this.editor.getSession().getAnnotations();
$("#node-input-python").val(this.editor.getValue());
this.editor.destroy();
delete this.editor;
},
oneditcancel: function() {
this.editor.destroy();
delete this.editor;
},
oneditresize: function(size) {
var rows = $("#dialog-form>div:not(.node-text-editor-row)");
var height = $("#dialog-form").height();
for (var i=0; i<rows.size(); i++) {
height -= $(rows[i]).outerHeight(true);
}
var editorRow = $("#dialog-form>div.node-text-editor-row");
height -= (parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom")));
$(".node-text-editor").css("height",height+"px");
this.editor.resize();
}
});
</script>