title: CreateRenderNode in maya and update the custom UI
body: <p>I am new to Python, so this might seem trivial. I've search all over the place to find an answer to my problem, but I can't seem to find it.</p>
  
  <p>I have a script, that is like a mini Hypeshade window and its main function is to create materials and load all the texture files that the user chose in one click. I want to have an option though for when the user wants to connect a noise or a checker for example to one of the file inputs (like bump, normal, etc.). This is done in maya by calling the "createRenderNode" window.</p>
  
  <p>Now, I have it workning and it connects to the input that I want to, but I also want to get the name of this file in the corresponding textField in my UI which it doesn't, since, when my function runs, it gets an empty string, as nothing is connected to it yet.</p>
  
  <p>Here is the code I have (I have tried so many iterations):</p>
  
  <pre><code># Error: 'NoneType' object is not iterable
  # Traceback (most recent call last):
  #   File "&lt;maya console&gt;", line 1, in &lt;module&gt;
  #   File "&lt;maya console&gt;", line 49, in brwa
  # TypeError: 'NoneType' object is not iterable #
  
  
  import maya.cmds as cmds
  import pymel.core as pm
  
  def UI():
  
      if cmds.window("MatWindow", exists = True):
          cmds.deleteUI("MatWindow")
  
      mainwindow = cmds.window("MatWindow", t="Dummy UI", bgc=(0.2,0.2,0.2), mnb = False, mxb = False) 
      cmds.columnLayout()
      cmds.rowColumnLayout(nr = 1)
      cmds.textFieldGrp('mtNameTxt', l = "Material Name")
      cmds.setParent ( '..' )
      cmds.columnLayout()
      cmds.button("createlamb", l = "Create Lambert", c = 'lamb()')
      cmds.setParent ( '..' )
      cmds.rowColumnLayout('albclm', nr = 1)   
      cmds.textFieldGrp('albtxt', l = "Albedo", pht = "Albedo Map")
      cmds.iconTextButton('conna', w = 25, h = 20, i = "navButtonUnconnected.png", c = 'brwa()')
      cmds.setParent( '..' )
      cmds.separator(h = 20)
      cmds.text("Insert a name first, then create the lambert, then try to load a texture")
      cmds.showWindow()
      cmds.window("MatWindow", e = 1, w=550, h=150, sizeable = 0)
  
  UI()
  
  #=========== Lambert ===========#    
  def lamb():
      matName = cmds.textFieldGrp('mtNameTxt', q = True, text = True)
      if cmds.objExists(matName) :
          cmds.confirmDialog( t = "Error", m = "Material name already exists, please choose another name.", b = "OK") 
      else :
          lambert = cmds.shadingNode("lambert", asShader = True, n = matName)
          shading_group = cmds.sets(r = True, nss = True, em = True, n = '%s_SG' %matName)
          cmds.connectAttr('%s.outColor' %matName ,'%s.surfaceShader' %shading_group)
  
  
  def brwa():
  
      matName = cmds.textFieldGrp('mtNameTxt', q = True, text = True)## this gets the material name from the UI
      brwsa = '%s.color' %matName
      pm.defaultNavigation(destination = brwsa, createNew = 1)
      pm.defaultNavigation(destination = brwsa, defaultTraversal = 1) ## this opens the createRenderNode window
      brwsafile = cmds.listConnections(brwsa) ## this gets the connected file
  
      for fileName in brwsafile:   
  
          def button_cmd(_):
              # _ is a dummy argument the button sends, but you can ignore it
              cmds.select(fileName)
  
          cmds.iconTextButton('conna', edit = 1, i = "navButtonConnected.png", c = button_cmd)
          cmds.textFieldGrp('albtxt', edit = 1, text = fileName)
  </code></pre>