Closed yilinxia closed 1 year ago
When using the following code
import jupyterlab_nodeeditor as jlne coll = jlne.SocketCollection(socket_types = ('Temperature', 'Rainfall', 'Delta Time', 'Results')) editor = jlne.NodeEditor(socket_collection=coll) in1 = jlne.InputSlot(title = "inputA", key = "in_1", sockets = coll, multi_connection=True) out1 = jlne.OutputSlot(title = "outputA", key = "out_1", sockets = coll,multi_connection=True) contrl1=jlne.TextInputControlModel(key = 'my_key', editor = editor.node_editor, value="./src/gs_lesson4_modelA.py") in2 = jlne.InputSlot(title = "inputB", key = "in_1", sockets = coll, multi_connection=True) out2 = jlne.OutputSlot(title = "outputB", key = "out_1", sockets = coll,multi_connection=True) contrl2=jlne.TextInputControlModel(key = 'my_key', editor = editor.node_editor, value="./src/gs_lesson4_modelB.py") new_comp1=jlne.Component(sockets=coll, inputs=[],outputs=[out1], controls=[contrl1],title="ModelA") new_comp2=jlne.Component(sockets=coll,inputs=[in2], outputs=[out2], controls=[contrl2],title="ModelB") new_node1=jlne.node_editor.NodeInstanceModel(sockets=coll,title="ModelA",inputs=[in1], outputs=[out1], controls=[contrl1]) new_node2=jlne.node_editor.NodeInstanceModel(sockets=coll,title="ModelB",inputs=[in2], outputs=[out2], controls=[contrl2])
we have sucessfully implemented the add_components function
add_components
editor.add_component(new_comp1) editor.add_component(new_comp2)
Ideally, we are trying to provide users two options
For option2, the current code only supports the following logic (without the editor, the seond line wont work)
editor editor.node_editor.nodes=editor.node_editor.nodes+[new_node1, new_node2]
However, we want to make it works as add_components, thus users can choose whether to show instance without printing editor at the very beginning
Notice No errors have been found in the console
When using the following code
we have sucessfully implemented the
add_components
functionIdeally, we are trying to provide users two options
For option2, the current code only supports the following logic (without the editor, the seond line wont work)
However, we want to make it works as
add_components
, thus users can choose whether to show instance without printing editor at the very beginningNotice No errors have been found in the console