Skip to content

NodeMenu

Akash Bora edited this page May 20, 2023 · 14 revisions

Node Menu

This is a built-in node search menu widget that can be used to store the node names and spawn them to canvas when selected.

node_menu

This is a modified class of this CTkScrollableDropdown widget which is similar to the tkinter menu widget.

Features

  • Spawns when double right clicked on the canvas
  • Spawns when <space-bar> is pressed
  • Has a node search feature (autocomplete)

Usage

def add_value_node():
    NodeValue(canvas, value=1)

canvas = NodeCanvas(root)
menu = NodeMenu(canvas)

menu.add_node(label="Value", command=add_value_node)
menu.add_node(label="Compile", command=lambda: NodeCompile(canvas))
...

Arguments

Parameter Description
attach parent widget to which the menu will be attached
width optional, change the default width of the menu
height optional, change the default height of the menu
fg_color change the fg_color of the menu frame
label change the top label text (search nodes)
button_color change the fg_color of the buttons/options
text_color change the text_color of the buttons/options
button_height change the height of the buttons if required
alpha change the transparency of the whole widget (range: 0-1)
justify change the anchor of the option text
frame_corner_radius adjust roundness of the frame corners
frame_border_width change the border_width of the frame if required
border_color change the border_color of the frame
scrollbar hide the scrollbar if required, default: False
Other Parameters some other parameters for the scrollbar and entry can also be passed

Note: menu colors are selected based on the customtkinter theme (default: Dark).

Methods

  • .add_node(label="node_name", command=add_node_func, *other_ctkbutton_args): this is the main command for adding the node to the menu contents.
  • .popup: popup the menu manually.
  • .withdraw: hides the popup.
  • .destroy_popup: destroy the menu from popup.