Where is the panel in 2.8?

i followed this tut on blender org

Blockquote

import bpy

class MyCustomMenu(bpy.types.Menu):

bl_label = "First Menu"
bl_idname = "OBJECT_MT_custom_menu"

def draw(self, context):

    layout = self.layout
    layout.label(text="Hello First Menu!", icon='WORLD_DATA')

     # call the second custom menu
    layout.menu("OBJECT_MT_sub_menu", icon="COLLAPSEMENU")

class MyCustomSubMenu(bpy.types.Menu):

bl_label = "Sub Menu"
bl_idname = "OBJECT_MT_sub_menu"

def draw(self, context):

    layout = self.layout
    layout.label(text="Hello Second Menu!", icon='WORLD_DATA')

    # call another predefined menu
    layout.operator("wm.call_menu", text="Unwrap").name = "VIEW3D_MT_uv_map" 

draw a button within the panel to call the first menu

class OBJECT_PT_my_panel(bpy.types.Panel):

def draw(self, context):
layout.operator(“wm.call_menu”, text=“Call My Menu”).name = “OBJECT_MT_custom_menu”

Blockquote

is there any indication in code where panel and menu will appear ?

thanks
happy bl

Since then (2016), a few small changes in the API have been made, mainly occurring between the 2.7x and 2.8 versions.

Something messed up with the formatting of panel code, but it doesn’t say which space type or region, and there is also the bl_category attribute if the panel is going into a side-bar, that is the name of the tab for it.

panels have to have:

bl_label
bl_space_type
bl_region_type

bl_category is optional

in some cases, bl_context is also needed, such as in the window region of the properties space

Even though it can be found in the manual, here is how to interrogate blender what the options are for space and region:

>>> bpy.types.Region.bl_rna.properties["type"].enum_items[:]
[<bpy_struct, EnumPropertyItem("WINDOW")>, <bpy_struct, EnumPropertyItem("HEADER")>, <bpy_struct, EnumPropertyItem("CHANNELS")>, <bpy_struct, EnumPropertyItem("TEMPORARY")>, <bpy_struct, EnumPropertyItem("UI")>, <bpy_struct, EnumPropertyItem("TOOLS")>, <bpy_struct, EnumPropertyItem("TOOL_PROPS")>, <bpy_struct, EnumPropertyItem("PREVIEW")>, <bpy_struct, EnumPropertyItem("HUD")>, <bpy_struct, EnumPropertyItem("NAVIGATION_BAR")>, <bpy_struct, EnumPropertyItem("EXECUTE")>, <bpy_struct, EnumPropertyItem("FOOTER")>, <bpy_struct, EnumPropertyItem("TOOL_HEADER")>]

>>> bpy.types.Space.bl_rna.properties["type"].enum_items[:]
[<bpy_struct, EnumPropertyItem("EMPTY")>, <bpy_struct, EnumPropertyItem("VIEW_3D")>, <bpy_struct, EnumPropertyItem("IMAGE_EDITOR")>, <bpy_struct, EnumPropertyItem("NODE_EDITOR")>, <bpy_struct, EnumPropertyItem("SEQUENCE_EDITOR")>, <bpy_struct, EnumPropertyItem("CLIP_EDITOR")>, <bpy_struct, EnumPropertyItem("DOPESHEET_EDITOR")>, <bpy_struct, EnumPropertyItem("GRAPH_EDITOR")>, <bpy_struct, EnumPropertyItem("NLA_EDITOR")>, <bpy_struct, EnumPropertyItem("TEXT_EDITOR")>, <bpy_struct, EnumPropertyItem("CONSOLE")>, <bpy_struct, EnumPropertyItem("INFO")>, <bpy_struct, EnumPropertyItem("TOPBAR")>, <bpy_struct, EnumPropertyItem("STATUSBAR")>, <bpy_struct, EnumPropertyItem("OUTLINER")>, <bpy_struct, EnumPropertyItem("PROPERTIES")>, <bpy_struct, EnumPropertyItem("FILE_BROWSER")>, <bpy_struct, EnumPropertyItem("PREFERENCES")>]

>>> 

If you want something in the n-key sidebar of the 3d viewport, that would be “UI” for the region type, “VIEW_3D” for the space type, and then use bl_category to set the name of the tab.

that page has things for panel in 2.8
so some works but this one does not !

will see if i can modif it to work in ui

but this already be in the that part code for this panel !
it is in the other ones for 2.8 LOL

thanks
happy bl

i added that for panel

class OBJECT_PT_my_panel(bpy.types.Panel):

bl_region_type = "UI"
bl_category = "Tools"
bl_options = {"DEFAULT_CLOSED"}

...
def draw(self, context):
    layout.operator("wm.call_menu", text="Call My Menu").name = "OBJECT_MT_custom_menu"

but still get error on menu !

ret = op_call(self.idname_py(), None, kw)

RuntimeError: Error: Menu “OBJECT_MT_simple_custom_menu” not found

what is is needed ?

thanks
happy bl

import bpy

class MyCustomMenu(bpy.types.Menu):
    bl_label = "First Menu"
    bl_idname = "OBJECT_MT_custom_menu"

    def draw(self, context):

        layout = self.layout
        layout.label(text="Hello First Menu!", icon='WORLD_DATA')

         # call the second custom menu
        layout.menu("OBJECT_MT_sub_menu", icon="COLLAPSEMENU")


class MyCustomSubMenu(bpy.types.Menu):
    bl_label = "Sub Menu"
    bl_idname = "OBJECT_MT_sub_menu"

    def draw(self, context):

        layout = self.layout
        layout.label(text="Hello Second Menu!", icon='WORLD_DATA')

        # call another predefined menu
        layout.operator("wm.call_menu", text="Unwrap").name = "VIEW3D_MT_uv_map" 


class OBJECT_PT_my_panel(bpy.types.Panel):
    bl_label = "Menu Panel"    
    bl_region_type = "UI"
    bl_space_type = 'VIEW_3D'    
    bl_category = "Tools"
    bl_options = {"DEFAULT_CLOSED"}
    
    def draw(self, context):
        
        layout = self.layout        
        layout.operator("wm.call_menu", text="Call My Menu").name = "OBJECT_MT_custom_menu"
    
    
    
def register():
    bpy.utils.register_class(OBJECT_PT_my_panel)
    bpy.utils.register_class(MyCustomSubMenu)
    bpy.utils.register_class(MyCustomMenu)
    
def unregister():
    bpy.utils.unregister_class(OBJECT_PT_my_panel)
    bpy.utils.unregister_class(MyCustomSubMenu)
    bpy.utils.unregister_class(MyCustomMenu)


if __name__ == "__main__":
    register()