From 040140e33d7ac8c39c3934601e571e973940031b Mon Sep 17 00:00:00 2001 From: ocogeclub Date: Sat, 29 Jan 2022 00:45:59 +0900 Subject: [PATCH] =?UTF-8?q?[update]=20spawn=E3=81=A7python=E3=82=B9?= =?UTF-8?q?=E3=82=AF=E3=83=AA=E3=83=97=E3=83=88=E3=82=92=E3=83=95=E3=82=A1?= =?UTF-8?q?=E3=82=A4=E3=83=AB=E5=90=8D=E3=81=A7=E5=91=BC=E3=81=B3=E5=87=BA?= =?UTF-8?q?=E3=81=9B=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 9 +++++++-- ugj_blocks.js | 38 +++++++++++--------------------------- 2 files changed, 18 insertions(+), 29 deletions(-) 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]; };