title: Maya Python: call function from other function with GUI
body: <p>so I'm kindof embarrassed to say: but my knowledge of calling functions from other functions is limited. I finished an auto rigging script that works perfectly: but I realized I can trim the fat according to another user by condensing alot of the repetitive commands by putting them into their own functions instead of using setAttr over and over again on different shapes. The problem is my knowledge on this trick is limited. It seems like if I screw with the *args in any of my function headers in anyway by adding any new function to it my script either ignores it or stops working outright.</p>
  <p>The script itself is relatively simple: after hitting &quot;build example curves&quot; what I want it to do is upon hitting &quot;Set Curve Color&quot; I want the setAttributes function to source the setColor function and change the color of the example curves</p>
  <p>if anyone can point me in the right path I would appreciate it, the instructions to install and run the script are at the end of the script:</p>
  <pre><code>'''
  import exampleScriptTemplate
  reload (exampleScriptTemplate)
  exampleScriptTemplate.gui()
  '''
  
  import maya.cmds as cmds
  
  if cmds.window(&quot;buildWin&quot;, exists =True):
      cmds.deleteUI(&quot;buildWin&quot;, window = True)
  
  myWindow = cmds.window(&quot;buildWin&quot;,t='DS_colorChanger',rtf=1,w=100, h=100, toolbox=True)
  column = cmds.columnLayout(adj=True)
  
  def gui(*args):
      cmds.columnLayout()
      cmds.button(w=300,label='build example curves',c=exampleShapes)
      cmds.colorIndexSliderGrp('controlColor',
          label='Control Color',
          min=0,
          max=31,
          value=1,
          columnWidth=[( 1, 80 ),( 2, 40 ), ( 3, 150 )])
      cmds.button(w=300,label='Set Curve Color',c=setAttrbutes)
      cmds.showWindow(myWindow)
      
  def exampleShapes(*args):
      cmds.circle(n='exampleCirc1',ch=False,nr = (0,0,0))
      cmds.circle(n='exampleCirc2',ch=False,nr = (0,0,0))
      cmds.circle(n='exampleCirc3',ch=False,nr = (0,0,0))
      
      cmds.setAttr('exampleCirc1.translateX',-2)
      cmds.setAttr('exampleCirc3.translateX',2)
      
  def setAttrbutes(setColor,*args):
      
      cmds.setAttr('exampleCirc1',setColor)
      cmds.setAttr('exampleCirc2',setColor)
      cmds.setAttr('exampleCirc3',setColor)
  
  def setColor(*args):
      colorPref = cmds.colorIndexSliderGrp('controlColor',query=True,value=True)
      colorPref = colorPref -1 
      
      cmds.setAttr('.overrideEnabled', 1)
      cmds.setAttr('.overrideColor', colorPref)
      
  '''
  To run this script:
     1.) Go to d:\Users\userName\Documents\maya\2020\scripts
     2.) Create a new python file named exampleScriptTemplate.py and paste the code in that file
     3.) open a python tab in the Maya script editor and run the following 3 lines:
          import exampleScriptTemplate
          reload (exampleScriptTemplate)
          exampleScriptTemplate.gui()
  '''
  </code></pre>