-
Notifications
You must be signed in to change notification settings - Fork 0
/
Node_1.py
36 lines (27 loc) · 1.32 KB
/
Node_1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import dearpygui.dearpygui as dpg
dpg.create_context()
# callback runs when user attempts to connect attributes
def link_callback(sender, app_data):
# app_data -> (link_id1, link_id2)
dpg.add_node_link(app_data[0], app_data[1], parent=sender)
# callback runs when user attempts to disconnect attributes
def delink_callback(sender, app_data):
# app_data -> link_id
dpg.delete_item(app_data)
with dpg.window(label="Tutorial", width=400, height=400):
with dpg.node_editor(callback=link_callback, delink_callback=delink_callback):
with dpg.node(label="Node 1"):
with dpg.node_attribute(label="Node A1"):
dpg.add_input_float(label="F1", width=150)
with dpg.node_attribute(label="Node A2", attribute_type=dpg.mvNode_Attr_Output):
dpg.add_input_float(label="F2", width=150)
with dpg.node(label="Node 2"):
with dpg.node_attribute(label="Node A3"):
dpg.add_input_float(label="F3", width=200)
with dpg.node_attribute(label="Node A4", attribute_type=dpg.mvNode_Attr_Output):
dpg.add_input_float(label="F4", width=200)
dpg.create_viewport(title='Custom Title', width=800, height=600)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()