Create a poll function for the purpose of graying out an operator

I’m working on an addon which has different functionalities for Cycles and Blender Render. Rather than have these options disappear when switching between modes, I’d prefer for them to just get grayed out. I’ve read you can do this by creating a poll function for an operator but I have no idea what the code for that looks like in application. Could anyone create or point me to a small example of this? Thanks.

e.g. check the template Operator Simple:

import bpy

def main(context):
    for ob in context.scene.objects:

class SimpleOperator(bpy.types.Operator):
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"

    def poll(cls, context):
        return context.active_object is not None

    def execute(self, context):
        return {'FINISHED'}

def register():
    bpy.types.VIEW3D_HT_header.prepend(lambda s, c: s.layout.operator("object.simple_operator"))

def unregister():

if __name__ == "__main__":

    # test call

I added a line of code to add a button of that operator to the 3d view header.

Delete the active object to make context.object equal to None. Poll function will return False and the button is grayed out.

Thankyou! This is excellent.