[update] spawnでpythonスクリプトをファイル名で呼び出せるように変更

This commit is contained in:
ocogeclub 2022-01-29 00:45:59 +09:00
parent 8c5e89853d
commit 040140e33d
2 changed files with 18 additions and 29 deletions

View File

@ -932,8 +932,13 @@
</shadow>
</value>
</block>
<block type="ugj_child_testpy"></block>
<block type="ugj_child_testjs"></block>
<block type="ugj_child_pyscript">
<value name="script_path">
<shadow type="text">
<field name="TEXT">test.py</field>
</shadow>
</value>
</block>
<label text="特殊記号" web-line="4.0" web-line-width="200"></label>
<block type="ugj_text_cr"></block>
<block type="ugj_text_lf"></block>

View File

@ -2949,39 +2949,23 @@ Blockly.JavaScript['ugj_child_irrcvr'] = function (block) {
return [code, Blockly.JavaScript.ORDER_NONE];
};
// Python との連携のひな型
Blockly.Blocks['ugj_child_testpy'] = {
// Python スクリプト
Blockly.Blocks['ugj_child_pyscript'] = {
init: function () {
this.appendDummyInput()
.appendField("testpy");
this.appendValueInput("script_path")
.setCheck("String")
.appendField("Pythonスクリプト :");
this.setInputsInline(true);
this.setOutput(true, "shcmd");
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
this.setStyle('special_blocks')
this.setTooltip("");
this.setTooltip("Pythonスクリプトファイル名");
this.setHelpUrl("");
this.setStyle('special_blocks');
}
};
Blockly.JavaScript['ugj_child_testpy'] = function (block) {
Blockly.JavaScript['ugj_child_pyscript'] = function (block) {
var value_script_path = Blockly.JavaScript.valueToCode(block, 'script_path', Blockly.JavaScript.ORDER_ATOMIC);
// TODO: Assemble JavaScript into code variable.
var code = "'python3', ['test.py']";
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.JavaScript.ORDER_NONE];
};
// 外部 Node との連携のひな型
Blockly.Blocks['ugj_child_testjs'] = {
init: function () {
this.appendDummyInput()
.appendField("testjs");
this.setOutput(true, "shcmd");
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
this.setStyle('special_blocks')
this.setTooltip("");
this.setHelpUrl("");
}
};
Blockly.JavaScript['ugj_child_testjs'] = function (block) {
// TODO: Assemble JavaScript into code variable.
var code = "'node', ['test.js']";
var code = `'python3', ['${elutil.doc_root}/' + ${value_script_path}]`;
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.JavaScript.ORDER_NONE];
};