I'm trying to write a script that creates a Pie menu, and I want the menu item on the [1] position (which calls another submenu) to be disabled whenever the current scene isn't "Some Scene".
I've tried doing
pie.menu("SOME_MT_Submenu", text='Some Submenu")
if context.scene.name != 'Some Scene':
pie.enabled = False
pie.menu("MENU_MT_Item", text = 'Menu item #2')
pie.menu("MENU_MT_Item", text = 'Menu item #3')
pie.menu("MENU_MT_Item", text = 'Menu item #4')
#and so on
...but it just disables the entire pie menu. I've also tried adding a @classmethod poll function on the Submenu, like;
class SOME_MT_Submenu(bpy.types.Menu)
bl_label = "Some Submenu"
@classmethod
def poll(cls, context):
return context.scene.name == 'Some Scene'
def draw(self, context):
layout = self.layout
layout.operator("some.operator", text = "Some Operator")
layout.operator("some.operator", text = "Some Operator")
layout.operator("some.operator", text = "Some Operator")
but whenever I run the script the menu item still calls out the submenu. And I've also tried adding the poll function to the 'Some Operator' class itself, and it still doesn't work.
I want that menu item to be grayed out and not call out the submenu when I hover over it. Is there a way to do that?