容器槽和子容器

大多数项都可以有子项。项只能是有效的子项 集装箱 物品。下面提供了一些相关命令:

is_item_container

检查项是否为容器类型

get_item_slot

返回项目的槽

get_item_parent

返回项目的父UUID

get_item_children

返回项的子项

reorder_items

一次呼叫即可对儿童进行重新排序

move_item_up

将项目在其槽内上移

move_item_down

将项目在其槽内下移

move_item

在容器之间移动项目

set_item_children

将舞台撤台到项目的子项位置

插槽

项目存储在其父容器内的目标槽中。以下是插槽的细分:

插槽0:

多维文件扩展名MvFontRangeHintMvNodeLink多维注释多维拖动线多点拖动点多维图例多维表格列

插槽1:

大多数项目

插槽2:

绘制项目

插槽3:

mvDragPayload

要查询项属于哪个槽,请使用 get_item_slot

基本示例

下面是一个简单的例子,它演示了上面的一些内容:

import dearpygui.dearpygui as dpg

dpg.create_context()

with dpg.window(label="about", width=400, height=400):
    dpg.add_button(label="Press me")
    dpg.draw_line((0, 10), (100, 100), color=(255, 0, 0, 255), thickness=1)

# print children
print(dpg.get_item_children(dpg.last_root()))

# print children in slot 1
print(dpg.get_item_children(dpg.last_root(), 1))

# check draw_line's slot
print(dpg.get_item_slot(dpg.last_item()))

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

备注

使用 slot 关键字与 get_item_children 以仅返回特定的槽。

备注

使用 slotchildren_only 关键字与 delete_item 若要从父项中删除特定的子项插槽,请执行以下操作。