I am assembling my first add-on and I have a particular order I would like my panels to stay in inside the UI. This is easily done by rearranging the order in which each panel is registered.
However, one of my panels I would like to hide it’s header and as soon as I use the bl_options to remove the header my panel jumps to the top of all my panel list.
I have a quick test code shown below with 3 panels. As you can see I have it setup so panel 3 shows up second in the panel UI. Run the script and you will see the 3 panels N Panel in the order as intended. Then un-comment the line "#bl_options = {‘HIDE_HEADER’}". Then IMPORTANT close blender. Reopen blender, run the script and the panel 3 header is hidden but it moves to the top of the list. If you DO NOT close Blender and rerun the script after the change the panel stays in place and hides the header…it appears to work. But this is the last UI register. You have to close Blender and reopen to get it to reset the UI and see the issue.
import bpy
def main(context):
for ob in context.scene.objects:
print(ob)
class SimpleOperator(bpy.types.Operator):
bl_idname = “object.simple_operator”
bl_label = “Simple Object Operator”
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
main(context)
return {'FINISHED'}
class HelloWorldPanel1(bpy.types.Panel):
bl_label = “Hello World Panel1”
bl_idname = “OBJECT_PT_hello1”
bl_space_type = ‘VIEW_3D’
bl_region_type = ‘UI’
bl_category = ‘Mine’
def draw(self, context):
layout = self.layout
row = layout.row()
row.operator("mesh.primitive_cube_add")
class HelloWorldPanel2(bpy.types.Panel):
bl_label = “Hello World Panel2”
bl_idname = “OBJECT_PT_hello2”
bl_space_type = ‘VIEW_3D’
bl_region_type = ‘UI’
bl_category = ‘Mine’
def draw(self, context):
layout = self.layout
row = layout.row()
row.operator("mesh.primitive_cube_add")
class HelloWorldPanel3(bpy.types.Panel):
bl_label = “Hello World Panel3”
bl_idname = “OBJECT_PT_hello3”
bl_space_type = ‘VIEW_3D’
bl_region_type = ‘UI’
bl_category = ‘Mine’
#bl_options = {‘HIDE_HEADER’}
def draw(self, context):
layout = self.layout
row = layout.row()
row.operator("mesh.primitive_cube_add")
classes = [
SimpleOperator,
HelloWorldPanel1,
HelloWorldPanel3,
HelloWorldPanel2,
]
def register():
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
for cls in classes:
bpy.utils.unregister_class(cls)
if name == “main”:
register()
Any ideas of how to keep this from happening would be greatly appreciated.
