diff --git a/index.html b/index.html index b46c93e..a15b715 100644 --- a/index.html +++ b/index.html @@ -932,8 +932,13 @@ - - + + + + test.py + + + diff --git a/ugj_blocks.js b/ugj_blocks.js index f36e7dd..6965d35 100644 --- a/ugj_blocks.js +++ b/ugj_blocks.js @@ -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]; };