- 
                Notifications
    
You must be signed in to change notification settings  - Fork 12
 
NodeCanvas
        Akash Bora edited this page May 17, 2023 
        ·
        8 revisions
      
    This is the parent widget where all nodes will be drawn. The wires/lines are placed under this class.
- 
We can add our own grid images in the canvas. (Make sure the image size is big enough)
Default grids are:
["lines", "dots", None] - 
It has drag and zoom ability, every canvas object is moved except the grid image.
 - 
It can save or load node trees.
 

root = tkinter.Tk()
canvas = NodeCanvas(root)
canvas.pack()
...| Parameter | Description | 
|---|---|
| master | parent widget to which the canvas will be attached | 
| bg | specify the bg color of canvas | 
| width | width of the canvas | 
| height | height of the canvas | 
| grid_image | paste the grid image to the canvas, default grid name: "lines" | 
| zoom | enable/disable the zoom feature (boolean) | 
| move | enable/disable the drag feature (boolean) | 
| wire_color | change the line colors of attached nodes | 
| wire_hover_color | change the activefill color of the lines | 
| wire_width | change the width of the lines | 
| wire_dash | enable/disable dotted lines (boolean) | 
- .configure(args...): change some attributes for the canvas like wire_colors, bg, grid_image etc.
 - 
.save(filename): save the node tree to a file. 
Eg: canvas.save("canvas.json") - 
.load(filename): load the node tree back to the canvas. 
Eg: canvas.load("canvas.json") - .clear(): deletes all the nodes from the canvas