Problem registering sub panel

error:
RuntimeError: Error: Registering panel class: parent 'VIEW3D_PT_mainPanel' for 'VIEW3D_PT_subPanel' not found

???
i tried various options:
1/ using: panels = (VIEW3D_PT_mainPanel’,VIEW3D_PT_subPanel)
… and register the panels

2/ using:Classes = (VIEW3D_PT_mainPanel’,VIEW3D_PT_subPanel)
… and register the classes as usual

i dont understand this in 2.8… when i register both classes and panels, it works for the main panel, BUT if it is a sub-panel, it doesn t work !

is there an orden for declaring the classes of panel and sub ? actually, i put the sub-panel declaration AFTER the main panel…

please, if you can explain or give me a tip on this :wink: thx

The order is important if both parent and child panels are custom. Register the parent panel first, then the child.

Example adding parent/child panels in Object tab

from bpy.types import Panel

# mixin so we don't have to define for each class
class ObjPanel(Panel):
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"

class OBJECT_PT_Parent(ObjPanel):
    bl_label = "Parent"
    def draw(self, context):
        self.layout.row().label(text="Parent panel")


class OBJECT_PT_Child(ObjPanel):
    bl_parent_id = "OBJECT_PT_Parent"
    bl_label = "Child"
    def draw(self, context):
        self.layout.row().label(text="Child panel")


def register():
    from bpy.utils import register_class
    register_class(OBJECT_PT_Parent)  # register first
    register_class(OBJECT_PT_Child)


if __name__ == "__main__":
    register()

How do we layout with these subpanels? To me it seems, they always are placed at the end of a parent_id layout. hence theres no way to place options and buttons below a subpanel. Not very useful, is it?