Build a panel row by row¶
Create a Floating Panel with two rows of buttons from the UIDs that each call returns, without comparing two reads.
panel = pme.create_pm(pme.PmCreationSpec("FPANEL", name="View Tools")).pm_uid
# A new Floating Panel has one row: its marker (slots[0]) and one button.
first_button = pme.editing.read_pm(panel)["slots"][1]["uid"]
# add_row() returns the new marker and its default button in created_uids,
# in that order (also slots[0] and slots[1]).
marker, second_button = pme.editing.add_row(panel)["created_uids"]
# add_slot() without a position appends a button to the last row and
# returns it as slots[0].
third_button = pme.editing.add_slot(panel)["slots"][0]["uid"]
pme.editing.update_slots(panel, {
first_button: {"mode": "PROP", "name": "Snap", "prop": "C.scene.tool_settings.use_snap"},
second_button: {"mode": "COMMAND", "name": "Frame", "cmd": "bpy.ops.view3d.view_selected()"},
third_button: {"mode": "COMMAND", "name": "All", "cmd": "bpy.ops.view3d.view_all()"},
})
Check¶
pme.editing.read_pm(panel)["rows"]has two rows. The first row’sslot_uidsare its marker andfirst_button; the second row’s aremarker,second_buttonandthird_button.The
update_slots()result hasstatus == "committed".