3

I can't find anywhere how can i add the panel of an operator in the Speaker properties data tab only. it appears in all other objects data tab and i can't find a context list

enter image description here

class HelloWorldPanel(bpy.types.Panel):
"""Creates a Panel in the Object properties window"""
bl_label = "Hello World Panel"
bl_idname = "OBJECT_PT_hello"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "data"

Thank you.

1 Answers1

5

Add a poll method.

To narrow it down could look to see if context object is of type 'SPEAKER' or since it is in the properties space, there is a speaker context member available when the object is not a speaker it will be none.

class HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "data"
@classmethod 
def poll(cls, context):
    return context.speaker is not None

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

    obj = context.object

    row = layout.row()
    row.label(text="Hello world!", icon='WORLD_DATA')

batFINGER
  • 84,216
  • 10
  • 108
  • 233