:vocab: developer-facing .. _authoring-recipe-build-panel-rows: ======================== Build a panel row by row ======================== .. py:currentmodule:: pme.editing Create a Floating Panel with two rows of buttons from the UIDs that each call returns, without comparing two reads. .. code-block:: python 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's ``slot_uids`` are its marker and ``first_button``; the second row's are ``marker``, ``second_button`` and ``third_button``. * The :py:func:`update_slots` result has ``status == "committed"``. Functions used ============== * :py:func:`pme.create_pm` * :py:func:`read_pm`, see :ref:`authoring-layout-rows` * :py:func:`add_row` * :py:func:`add_slot` * :py:func:`update_slots`