How do I detect a modifier with a specific name and type to disable a row.operator?

How do I detect the presence of specific modifier of a specific name and type and use this to create an if/else statement to disable a row.operator(Button) in my custom panel ?

import bpy


for i in bpy.context.object.modifiers:
    if i.type =='SUBSURF' and i.name == 'Subsurf':
        row.operator(Button)       
        break

That’s what you want.

If you want to be pythonic:


    if 'Subsurf' in i.name and i.type == 'SUBSURF':
        row.enabled = False

You can also save UI elements into a variable before hand.


    slots = [None] * 12
    for i in slots:
        slots[i] = row.operator(??)

    slots[n].enabled = False
    del slots  # don't have to