Test if a UI operator is enabled.

Sorry for asking so many questions but hopefully these will help others as well.
I am building a list of operators.
The list is large and I would like to not even show operators that would be otherwise be disabled.

I have tried to track down how the C selects which operators to enable and I can’t track it down.
I would like to either duplicate the process in python or be able to read the state of an operator prior to creating it.
Does anyone know where in the C this is done so I can duplicate it or if there is a way to test it in python.
poll() is not reliable enough.

Thanks
Yardie

Not sure what you mean, poll() and its C-equivalent determine whether a button is enabled or disabled.

If poll() returns True, but the button is still grayed out in UI, then it’s done in the layout only, e.g.:

col = layout.column()
col.enabled = False
col.operator(…)

enabled - if False, it’s grayed out and user can’t click:
http://www.blender.org/documentation/blender_python_api_2_71_release/bpy.types.UILayout.html?highlight=uilayout#bpy.types.UILayout.enabled

active - if False, it’s grayed out, but the user can still click:
http://www.blender.org/documentation/blender_python_api_2_71_release/bpy.types.UILayout.html?highlight=uilayout#bpy.types.UILayout.active

To access these properties without reference to the layout object is AFAIK only possible if you intercept all UILayout calls as shown here:
http://wiki.blender.org/index.php?title=Dev:2.5/Py/Scripts/Cookbook/Code_snippets/Interface&oldid=226944#Overriding_Interface_Elements

Thanks CoDEmanX
I stuffed up and the poll() is working correctly enough for what I am doing.
Thank you for being so tolerant and giving some very useful information all the way along this little journey.
If you come to Western Australia I will buy you a beer. :smiley:
The code will retain credits to you.