Operator addons with multiple texture inputs in Python I'm fairly new to Python in Blender and working on an add-on to allow users to input their textures without accessing the node editor. I take reference from some of the codings within this website and create an add-on with one file input but still getting struck on how to do multiple ones(e.g. diffuse, rough, normal).

Here is my original script for one file input:
import bpy
from bpy.props import StringProperty, PointerProperty

class MaterialRoughnessPanel(bpy.types.Panel):
    
    bl_label = &quot;Texture Input&quot;
    bl_idname = &quot;MATERIAL_PT_PANEL&quot;
    bl_space_type = &quot;VIEW_3D&quot;
    bl_region_type = &quot;UI&quot;
    bl_category = &quot;Material Parameter&quot;
    
    def draw(self, context):
        layout = self.layout
        ob = bpy.context.active_object
        ma =ob.active_material
        row=layout.row()
        row.prop(ma.slot_setting, &quot;rough&quot;)  

def updateRough(self, context):
    
    mat = self.id_data
    node = mat.node_tree.nodes
    nodes = [k for k in node
            if isinstance(k,  bpy.types.ShaderNodeTexImage)]    
      
    for k in nodes:
        k.image = bpy.data.images.load(self.rough)
        return k
        
class roughSet(bpy.types.PropertyGroup):

    rough: StringProperty(
            name=&quot;ROUGH&quot;,
            subtype='FILE_PATH',
            update = updateRough) 

def register():
    bpy.utils.register_class(MaterialRoughnessPanel)
    bpy.utils.register_class(roughSet)
    bpy.types.Material.slot_setting=PointerProperty(type=roughSet)


    
def unregister():
    bpy.utils.register_class(MaterialRoughnessPanel)
    bpy.utils.register_class(roughSet)
    del bpy.types.Material.slot_setting

if __name__ == &quot;__main__&quot;:
    register()

I try to do multiple inputs by telling Blender to access the maps with if...else condition. The script can execute but it seems that Blender is confused about the condition and texture input is not working as usual.
Here is the excerpt of the script:
def updateMat(self, context):
    
    mat = self.id_data
    node = mat.node_tree.nodes
    prxy = bpy.types.ShaderNodeBsdfPrincipled
    img = bpy.types.ShaderNodeTextImage
    imgdif = bpy.types.ShaderNoteTextImage
    if mat.node_tree.links.new(img.outputs[0], prxy.inputs[5]):
        spec = img

        nodes = [k for k in node
                if isinstance(k, spec)]    
      
        for k in nodes:
            k.image = bpy.data.images.load(self.rough)
            return k
    elif mat.node_tree.links.new(img.outputs[0], prxy.inputs[0]):
        dif = imgdif

        secNode = [s for s in node
                if isinstance(k, dif)]    
      
        for s in secNode:
            s.image = bpy.data.images.load(self.diffuse)
            return s
        
class materialSet(bpy.types.PropertyGroup):

    rough: StringProperty(
            name=&quot;SPEC&quot;,
            subtype='FILE_PATH',
            update = updateMat) 
    diffuse: StringProperty(name=&quot;DIFFUSE&quot;,
            subtype='FILE_PATH',
            update = updateMat)
I figured it out. I'd tried to think too much and the solution can be very simple. As nodes variable is already a list, I can simply tell the system which map belong to diffuse etc.
Instead of
 if mat.node_tree.links.new(img.outputs[0], prxy.inputs[5]):
        spec = img

        nodes = [k for k in node
                if isinstance(k, spec)]    
      
        for k in nodes:
            k.image = bpy.data.images.load(self.rough)
            return k
    elif mat.node_tree.links.new(img.outputs[0], prxy.inputs[0]):
        dif = imgdif

        secNode = [s for s in node
                if isinstance(k, dif)]    
      
        for s in secNode:
            s.image = bpy.data.images.load(self.diffuse)
            return s

I have done something like:
mat = self.id_data
node = mat.node_tree.nodes
img = bpy.types.ShaderNodeTexImage
nodes = [k for k in node
         if isinstance(k,img)]    
nodes[0].image = bpy.data.images.load(self.rough)
nodes[1].image =bpy.data.images.load(self.spec)