-
Notifications
You must be signed in to change notification settings - Fork 11
NodeTypes: NodeOperation
Akash Bora edited this page Jan 28, 2024
·
14 revisions
Node Operation is a node which processes inputs through a command/function and return a new output. It has:
- Multiple inputs (upto 5)
- One-to-one connections
- Multisided sockets
def func(x,y):
# x and y are 2 inputs from the node,
# do some work with the inputs and return the final value
return x+y
node = NodeOperation(canvas, text="Function", inputs=2, command=func)
Parameter | Description |
---|---|
canvas | parent canvas where the node will be spawn |
height | height of the node |
width | width of the node |
inputs | number of input sockets in the node |
fg_color | foreground color of the node |
text | change the text of the node |
text_color | change the text color |
font | change the font of text |
justify | change the text anchor |
highlightcolor | hover color of the node |
border_width | adds an additional border to the nodes |
border_color | border color of the node if border_width>0 |
hover | disable/enable the hover effect |
socket_color | change the color of the input sockets, type: string or list of colors |
output_socket_color | change the color of the output socket |
socket_hover_color | change the hover color of the sockets |
multiple_connection | connect multiple nodes to one input, returns a list |
pass_node_id | pass node id in the command (bool) |
socket_hover | enable/disable the socket hover |
socket_radius | change the size of the sockets |
corner_radius | change the roundness of the node frame |
multiside | enable/disable multisided sockets |
x | specify the x spawn location |
y | specify the y spawn location |
fixed | removes the delete key binding, makes the node non-removable |
command | add the main command when the node is connected |
none_inputs | calls the command even if none values are passed (default: False) |
click_command | add a command when the node is clicked |
-
.configure(args...): change some attributes of the node.
-
.config_socket(index, args...): configure individual sockets
You can also add a small hover tooltip over the socket using this method.
Eg:
node.config_socket(1, hover_text="socket info", hover_text_color="black", hover_bg="white", socket_color="blue")
-
.get(): get the output of the node/
-
.get_inputs(): get the values of attached inputs.
-
.destroy(): deletes the node from the canvas.
-
.exists(): check if node exist in the canvas.