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$
2
$\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$
  • $\begingroup$ Well, that's crystal clear ! Thank you very much !! $\endgroup$ – Nikos_VSE Aug 9 '14 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.