Post #4811: ‘L’ is an instance of UILayout available in the custom tabs of PME. While you ca

📋 Metadata

🏷️ Tags

scripting intermediate solved

  • Custom Tabs
  • Python Scripting
  • UILayout Integration

💬 Content

‘L’ is an instance of UILayout available in the custom tabs of PME. While you can create a basic UI using command tabs or property tabs, the custom tab allows you to use UILayout, offering the ability to create a more flexible UI.

Pie Menu Editor | Scripting
You can verify other usable global variables and functions in the PME documentation.
UILayout Official Reference
I’ll repost the link to the official reference for UILayout for your convenience.


To understand what UILayout is, let’s look at an example of using UILayout in standard Blender UI creation. If you want to create your custom panel, you make a class that inherits from bpy.types.Panel and define (override) the draw method within it. Within this draw method, you access the instance of UILayout using the self.layout code and add UI elements.

class MyCustomPanel(bpy.types.Panel):
    bl_idname = "MyCustomPanel"

    def draw(self, context):
        layout = self.layout

        # Add a new row and a label to it
        row = layout.row()
        row.label(text="Hello, World!")

        # Add another row and an operator button to it
        row = layout.row()
        row.operator("mesh.primitive_cube_add", text="Add Cube")

        # Add one more row and a property input to it
        row = layout.row()
        row.prop(context.object, "scale")

In the example above, UILayout (here self.layout) is used to create a new row and add labels, buttons, or property inputs to that row. This creates a layout for the UI.

For further details, please refer to this video.
Scripting for Artists | User Interfaces


On the other hand, ‘L’ in PME also refers to an instance of UILayout. However, due to the characteristics of PME, the scope of ‘L’ within PME is limited to the specific item because it is used to individually set the layout for each menu item. Nonetheless, the basic method of adding rows, labels, buttons, property inputs, etc., using UILayout remains the same.

Let’s look at the previous post as an example.

L.row().prop(C.object, 'location')



L.column().prop(C.object, 'location')

Both display the object’s location information, but each specifies whether to display it horizontally or vertically. To display on the Tool Header, it needed to be displayed horizontally, but Object.location seemed to be automatically displayed vertically, so the row() method was used to specify the horizontal direction.

I am not very knowledgeable about UILayout myself, but mastering it should allow for the creation of more advanced UIs.


❤️ 2 likes


🔗 View on Blender Artists