-
Notifications
You must be signed in to change notification settings - Fork 12
NodeTypes: NodeOperation
Akash Bora edited this page Jun 1, 2023
·
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)
- 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 |
| 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 |
| 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.
configure socket color individually like this:
node.configure(socket_color_1="red") -
.config_socket(index, hover_text, hover_text_color, hover_bg, socket_color, ...: configure individual sockets

You can also add a small hover tooltip over the socket using this method.
-
.destroy(): deletes the node from the canvas.
-
.exists(): check if node exist in the canvas.