0
$\begingroup$

When making a Custom panel in the UI for Blender, is there any way to make it easier to navigate?

for example making the background color in a "Drop down menu" a bit darker. or maybe borders around the buttons that are meant to be used together.

Like in this picture it is obvious that these settings are for Locking because it has a darker background.

In this picture you can see the slightly darker background i want to use

thank you

edit: another image for clarity

enter image description here

$\endgroup$
2
  • $\begingroup$ That is mostly taken care of automatically when you categorize your panel hierarchy and properties layout, and usually responds to user Blender theme set in user preferences. Not something that would generally need much manual crafting. What is missing in your case? $\endgroup$ Commented Jul 18, 2022 at 14:52
  • $\begingroup$ Hello I added another picture so you can more clearly see what I am trying to do $\endgroup$ Commented Jul 18, 2022 at 15:06

1 Answer 1

1
$\begingroup$

View Lock is darker because it is a child of the View Panel.

API - https://docs.blender.org/api/current/bpy.types.Panel.html

To make to a layout similar to the blender layout use

import bpy


class LayoutDemoPanel(bpy.types.Panel):
    """Creates a Panel in the scene context of the properties editor"""
    bl_label = "Layout Parent"
    bl_idname = "SCENE_PT_layout"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = "Demo"

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False
        
        layout.label(text='Parent')
        
        
class LayoutDemoPanelChild(bpy.types.Panel):
    """Creates a Panel in the scene context of the properties editor"""
    bl_label = "Layout Child"
    bl_idname = "SCENE_PT_layout_child"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = "Demo"
    bl_parent_id = "SCENE_PT_layout"

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False
        
        layout.label(text='Child')
        
        
def register():
    bpy.utils.register_class(LayoutDemoPanel)
    bpy.utils.register_class(LayoutDemoPanelChild)


def unregister():
    bpy.utils.unregister_class(LayoutDemoPanel)
    bpy.utils.unregister_class(LayoutDemoPanelChild)


if __name__ == "__main__":
    register()
$\endgroup$
2
  • $\begingroup$ Thanks! I will use this method from now on, how do I specify the position where each child is going to be in the Parent panel? $\endgroup$ Commented Jul 18, 2022 at 15:45
  • $\begingroup$ use bl_order for more visit- docs.blender.org/api/current/bpy.types.Panel.html $\endgroup$
    – Karan
    Commented Jul 18, 2022 at 15:48

Not the answer you're looking for? Browse other questions tagged .