title: How do I lock these attributes?
body: <p>I've only just started coding, so I thought I would try and make something simple, however, I can't select the objects from my <code>ls</code>, I know the error is in my <code>def attrLockT</code> and was wondering if anyone could help me to fix this issue and understand what I am doing wrong?</p>
  
  <pre class="lang-py prettyprint-override"><code>import maya.cmds as cmds
  
  #Selects the attributes
  
  sat = ['.tx', '.ty', '.tz']
  sar = ['.rx', '.ry', '.rz']
  sas = ['.sx', '.sy', '.sz']
  
  #Creates the list of currently selected objects
  
  myList = cmds.ls(sl = True)
  
  #Lock the translate attributes of the selected objects
  
  def attrLockT(*args):
      checkAttr=cmds.getAttr (myList[0] + sat)
  
      if (checkAttr == 0):
          cmds.setAttr(myList[0] + sat, lock = 1)
  
  #Delete window if it is already open
  if cmds.window('animationCtrl', exists=True):
      cmds.deleteUI('animationCtrl', window=True)
  
  #Setup the window
  cmds.window(
      'animationCtrl',
      title = "Animation Controls",
      widthHeight = (300, 500),
      s = False)
  
  form = cmds.formLayout()
  tabs = cmds.tabLayout(innerMarginWidth=5, innerMarginHeight=5)
  cmds.formLayout(
      form, 
      edit=True,
      attachForm=(
          (tabs, 'top', 0),
          (tabs, 'left', 0),
          (tabs, 'bottom', 0),
          (tabs, 'right', 0)))
  
  
  #Layout for the first tab
  child1 = cmds.gridLayout( numberOfRowsColumns=(4, 3) , cwh = (100, 50))
  cmds.text(label = "")
  cmds.text(label = "Lock", align = "center", h = 20, w = 250)
  cmds.text(label = "")
  cmds.button(label = "Translate", h = 300, w = 250, c = attrLockT)
  cmds.button(label = "Rotate", h = 50, w = 250)
  cmds.button(label = "Scale", h = 50, w = 250)
  cmds.text(label = "")
  cmds.text(label = "Unlock", align = "center", h = 20, w = 250)
  cmds.text(label = "")
  cmds.button(label = "Translate", h = 50, w = 250)
  cmds.button(label = "Rotate", h = 50, w = 250)
  cmds.button(label = "Scale", h = 50, w = 250)
  cmds.setParent( '..' )
  
  #Layout for the second tab
  child2 = cmds.rowColumnLayout(numberOfColumns=3)
  cmds.button()
  cmds.button()
  cmds.button()
  cmds.setParent( '..' )
  
  cmds.tabLayout(
      tabs,
      edit=True,
      tabLabel=((child1, 'Lock/Unlock'), (child2, 'Keyable/Unkeyable')))
  
  cmds.showWindow('animationCtrl')
  </code></pre>
  
  <p>The error that is thrown is</p>
  
  <pre><code># Error: coercing to Unicode: need string or buffer, list found
  # Traceback (most recent call last):
  #   File "&lt;maya console&gt;", line 16, in attrLockT
  # TypeError: coercing to Unicode: need string or buffer, list found 
  </code></pre>