2
$\begingroup$

I try to display a custom property of a 3D object belonging to scene A in a panel that only appears in scene B.

At the time of the initialization : The scene A (that will be set by the user) it's not defined yet. So the panel shouldn't be shown. Also, when no object is active in the scene A, the panel should be hidden.

So far, here's my code :

class tags_panel(bpy.types.Panel):     
    bl_space_type = "SEQUENCE_EDITOR"       
    bl_region_type = "UI"          
    bl_label = "zebra"           

    @classmethod
    def poll(cls, context):
        if bpy.context.screen.scene.name == 'B':
            return

    def draw(self, context):
        global main_scene
        try:
            self.layout.prop(main_scene.objects.active, "my_prop")
        except NameError: 
            print("something wrong...")

For now the panel is not showing.

Can someone explain me the use of poll() and how I can manage to display the panel only if all conditions are met ? Thank you so much !

$\endgroup$

1 Answer 1

3
$\begingroup$

A panel disappears if poll() returns False:

    @classmethod
    def poll(cls, context):
        return context.scene.name == 'B'

If Scene.name is equal to 'B', it will show.

$\endgroup$
1
  • $\begingroup$ Well, that's crystal clear ! Thank you very much !! $\endgroup$
    – Nikos_VSE
    Commented Aug 9, 2014 at 14:26

You must log in to answer this question.

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