r/DearPyGui • u/mark1734jd • Nov 05 '23
Help dearpygui node editor
I don’t understand how to make the nodes accept some values.
import dearpygui.dearpygui as dpg# import mathdpg.create_context()dpg.set_global_font_scale(1.3)
def input_node(appdata, user_data, sender):a = [500.0, 300.0]with dpg.node(label="input node", parent="node_editor", pos=a):with dpg.node_attribute(attribute_type=dpg.mvNode_Attr_Output):dpg.add_input_float(width=200)
def output_node(appdata, user_data, sender):a = [500.0, 300.0]with dpg.node(label="output node", parent="node_editor", pos=a):with dpg.node_attribute(attribute_type=dpg.mvNode_Attr_Input):dpg.add_input_float(width=200)print(f"\n {appdata} \n {user_data} \n {sender}")
def delete():for i in dpg.get_selected_nodes("node_editor"):dpg.delete_item(i)
def link_callback(sender, app_data):dpg.add_node_link(app_data[0], app_data[1], parent=sender)
def delink_callback(sender, app_data):dpg.delete_item(app_data)
with dpg.window(tag="root"):dpg.add_node_editor(tag="node_editor", callback=link_callback, delink_callback=delink_callback, minimap=True,minimap_location=dpg.mvNodeMiniMap_Location_BottomRight)with dpg.menu_bar(tag="main menu bar"):with dpg.menu(label="input/output nods"):dpg.add_menu_item(label="New input node", callback=input_node)dpg.add_menu_item(label="New output node", callback=output_node)with dpg.menu(label="calculation nods"):dpg.add_menu_item(label="New output node", callback=delete)dpg.add_menu_item(label="Delete node", callback=delete)# dpg.add_menu_item(label="Copy node")dpg.create_viewport(title='node editor')dpg.set_primary_window("root", True)dpg.create_viewport()dpg.setup_dearpygui()dpg.show_viewport()dpg.start_dearpygui()dpg.destroy_context()
View all comments
1
u/reddittestpilot Silver Nov 05 '23
You might want to take a look at apps that offer the node editor functionality.
https://github.com/hoffstadt/DearPyGui/wiki/Dear-PyGui-Showcase#image-processing-node-editor
https://github.com/hoffstadt/DearPyGui/wiki/Dear-PyGui-Showcase#wedx
https://github.com/hoffstadt/DearPyGui/wiki/Dear-PyGui-Showcase#heron-a-hybrid-approach-to-data-pipelines-in-python
https://github.com/farzadshayanfar/nodiumpy
https://github.com/yslib/Cameray