-
Notifications
You must be signed in to change notification settings - Fork 10
Usage
Akash Bora edited this page May 19, 2023
·
5 revisions
The workflow is very simple:
- place the NodeCanvas widget in your application,
- add the NodeMenu,
- store the node types in the menu (using
.add_node
), - write commands/functions and values for the node types,
- run the script, spawn the nodes through the node menu and play.
You can also place nodes in the canvas by default.
from tknodesystem import *
import tkinter
root = tkinter.Tk()
# Add Node Canvas
canvas = NodeCanvas(root)
canvas.pack(fill="both", expand=True)
# Place some default nodes in the canvas
NodeValue(canvas, x=0, y=10) # x and y are not necessary arguments
NodeOperation(canvas, x=150, y=1)
NodeCompile(canvas, x=300, y=10)
# Add the NodeMenu and spawn new nodes.
menu = NodeMenu(canvas) # right click or press <space> to spawn the node menu
menu.add_node(label="NodeValue", command=lambda: NodeValue(canvas))
menu.add_node(label="NodeOperation", command=lambda: NodeOperation(canvas))
menu.add_node(label="NodeCompile", command=lambda: NodeCompile(canvas))
root.mainloop()
Other examples are given the examples
folder of the repository.