Search code examples
pythonmaya

Python Maya: access result of a function when called in button flag


I am working on UI window with a browse button. I have a browsePath function that I am calling in a cmds.button command. How can I get the output of browsePath() in my main function?

def main():
   cmds.button(label='Browse', command=browsePath)
def browsePath(*args):
   path = cmds.fileDialog2(fm=2)
   if path:
       cmds.textField('txt', tx=path[0])
   return path

Solution

  • I don't think so maya gui events return anything, you probaly need to relay on a variable outside. But since you already getting the path value to your textField you can always query the textField value where you want.