error 1009 occurs in dearpygui python program

33 Views Asked by At

when I click on the button for the first time everything is fine, but when I click on it the second time an error occurs "It looks like your post is mostly code; please add some more details." "It looks like your post is mostly code; please add some more details." "It looks like your post is mostly code; please add some more details."

import dearpygui.dearpygui as dpg
import math

dpg.create_context()
dpg.set_global_font_scale(1.3)


def my_atom_node(appdata, user_data, sender):
    a = dpg.get_mouse_pos()
    with dpg.node(label="atom_node", parent="node_editor"):
        with dpg.node_attribute(attribute_type=dpg.mvNode_Attr_Input, tag="attribute for floats"):
            pass
        with dpg.node_attribute(attribute_type=dpg.mvNode_Attr_Output):
            with dpg.drawlist(height=200, width=250, tag="draw_list_ept"):
                with dpg.draw_node(tag="root node"):
                    dpg.draw_circle([0, 0], 60, color=[0, 255, 0])
                    dpg.draw_circle([0, 0], 100, color=[0, 255, 255])
                    dpg.draw_circle([0, 0], 15, color=[255, 255, 0], fill=[255, 255, 0])

                    with dpg.draw_node(tag="planet node 1"):
                        dpg.draw_circle([0, 0], 10, color=[255, 0, 255], fill=[255, 0, 255])

                    with dpg.draw_node(tag="planet node 2"):
                        dpg.draw_circle([0, 0], 10, color=[0, 0, 255], fill=[0, 0, 255])

                planet_1_distance = 60
                planet_2_distance = 100

                dpg.apply_transform("root node", dpg.create_translation_matrix([100, 100]))

                def transform_ept_1(appdata, user_data, sender):
                    planet_1_angle = user_data
                    dpg.apply_transform("planet node 1",
                                        dpg.create_rotation_matrix(math.pi * planet_1_angle / 180.0, [0, 0, -1])
                                        * dpg.create_translation_matrix([planet_1_distance, 0]))

                def transform_ept_2(appdata, user_data, sender):
                    planet_2_angle = user_data
                    dpg.apply_transform("planet node 2",
                                        dpg.create_rotation_matrix(math.pi * planet_2_angle / 180.0, [0, 0, -1])
                                        * dpg.create_translation_matrix([planet_2_distance, 0]))

            dpg.add_input_float(width=200, label="planet 1", max_value=400, format="%.06f",
                                                       parent="attribute for floats", callback=transform_ept_1)
            dpg.add_input_float(width=200, label="planet 2", max_value=400, format="%.06f",
                                                       parent="attribute for floats", callback=transform_ept_2)


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.window(width=400, height=300, tag="root_2"):
    dpg.add_button(label="New atom node", callback=my_atom_node)

dpg.create_viewport(title='Custom Title', width=800, height=600)
dpg.set_primary_window("root", True)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()

This is my first time asking a question here, so I don’t know what to write here

0

There are 0 best solutions below