Skip to content

Conversation

@nvglucifer
Copy link
Contributor


name: Pull Request
about: adding move_item's functionality to configure_item.
title: feat (configure_item): add move_item's functionality to configure_item
assignees: @hoffstadt


Description:
Able to use kwargs parent/before in configure_item.
Closes #1963

Test moving item around with configure_item:

import dearpygui.dearpygui as dpg

dpg.create_context()
dpg.create_viewport()

def move_to_other_child(s, a, u):
    child_1_childs = dpg.get_item_children(child_1, slot=1)
    child_2_childs = dpg.get_item_children(child_2, slot=1)

    if dpg.get_item_label(s) == "<<<":
        if len(child_2_childs) == 1: return

        item, before = dpg.get_item_alias(child_2_childs[0]), dpg.get_item_alias(child_1_childs[0])
        dpg.configure_item(item, before=before),
        dpg.configure_item(spacer, height=dpg.get_item_rect_size(child_1)[1]-25)

    elif dpg.get_item_label(s) == ">>>":
        if len(child_1_childs) == 1: return

        dpg.configure_item(child_1_childs[-1], parent=child_2),
        dpg.configure_item(spacer, height=dpg.get_item_rect_size(child_1)[1]-50)


with dpg.window(autosize=True):
    with dpg.group(horizontal=True):

        with dpg.child_window(auto_resize_x=True, auto_resize_y=True) as child_1:
            for i in range(0, 10):
                dpg.add_button(label=f"btn_{i}", tag=f"btn_{i}")

        with dpg.group():
            dpg.add_button(label="<<<", callback=move_to_other_child)
            spacer = dpg.add_spacer(height=1)
            dpg.add_button(label=">>>", callback=move_to_other_child)

            dpg.set_frame_callback(5, lambda: dpg.configure_item(
                spacer, height=dpg.get_item_rect_size(child_1)[1]-50))

        with dpg.child_window(auto_resize_x=True, auto_resize_y=True) as child_2:
            for i in range(10, 20):
                dpg.add_button(label=f"btn_{i}", tag=f"btn_{i}")

dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
Able to use kwargs parent/before in configure_item.
@nvglucifer nvglucifer requested a review from hoffstadt as a code owner May 10, 2025 02:24
@v-ein v-ein self-requested a review June 20, 2025 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant