-
Notifications
You must be signed in to change notification settings - Fork 12
NodeMenu
Akash Bora edited this page May 17, 2023
·
14 revisions
This is a built-in menu widget that can be used to store the node types and spawn them to canvas when selected.

This is a modified class of this CTkScrollableDropdown widget. Use this widget like tkinter menu widget.
- Spawns when
double right clickedon the canvas - Spawns when
<space-bar>is pressed - Has a node search feature
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)) ...
| 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).
- **.add_node(label="node_name", command=spawn_node, other_ctkbutton_args): main command for adding the node to menu contents.
- .popup: popup the menu manually.
- .withdraw: hides the popup.
- .destroy_popup: destroy the menu from popup.