Is it possible to determine the UI panel class that is parent/host to an operator when its button is clicked? I'm dynamically registering a variable number of panel classes, all sub-classed from a custom panel class that includes an operator. Thus all the new panel sub-classes contain a button that executes this common, ancestral operator code. When the button on one of these new sub-class panels is clicked I would like the operator code to be able to determine which of the panel/button instances invoked it. Is such a thing possible? My apologies if I've not described this very clearly. Basically I'm trying to recreate the same functionality as the 'X' button that sits in the header of modifiers sub-panels. In my example, the code behind the X button needs to know which panel class the clicked button belongs to in order to unregister the correct panel. Any advice is greatly welcomed and appreciated. Thank you!
You can define a property for the operator in order to identify something.
For instance:
class SimpleOperator(bpy.types.Operator):
    &quot;&quot;&quot;Tooltip&quot;&quot;&quot;
    bl_idname = &quot;object.simple_operator&quot;
    bl_label = &quot;Simple Object Operator&quot;

    # &gt;&gt;&gt;&gt; Declare a property
    some_value = IntProperty(default=0)

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

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

Then, in the panel you can assign the property value as you want:
class HelloWorldPanel(bpy.types.Panel):
    &quot;&quot;&quot;Creates a Panel in the Object properties window&quot;&quot;&quot;
    bl_label = &quot;Hello World Panel&quot;
    bl_idname = &quot;OBJECT_PT_hello&quot;
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = &quot;object&quot;

    def draw(self, context):
        layout = self.layout

        row = layout.row()
        op = row.operator(&quot;object.simple_operator&quot;)
        # &gt;&gt;&gt;&gt; Assign its value
        op.some_value = 1
        op = row.operator(&quot;object.simple_operator&quot;)
        # &gt;&gt;&gt;&gt; Assign its value
        op.some_value = 2

Alternatively, you can assign the value in a subclass if your want to work with subclasses.