Print to Info or grey out a button if no object is selected - Python script How would you print to the info if no object is selected (no active object), or grey out the buttons for a script that is operating on a mesh object? I understand you could run a
self.report({'INFO'}, 'No Object Selected!')

in a execute function, but I already have an execute function for my Operator which is running fine when an object is selected. Basically I either need a grayed out button when no object is selected, or an error report telling the user to select an object first. I believe this might be possible with a Poll, but I don't know how to write it to check for an active object or not and print error to info, etc.
The poll function of your operator is suitable for this check indeed.
Just let it check whether an object is selected/active in the current context and return a boolean:
import bpy

class HelloObjectOperator(bpy.types.Operator):
    bl_idname = &quot;obj.hello&quot;
    bl_label = &quot;Minimal Object Operator&quot;

    @classmethod
    def poll(cls, context):
        return context.object is not None

    def execute(self, context):
        print(&quot;Hello&quot;, context.object.name)
        return {'FINISHED'}

bpy.utils.register_class(HelloObjectOperator)

When adding your operator in a panel somewhere:
layout.operator(&quot;obj.hello&quot;)

The button will automatically grey out when no object is active.