Python 如何一次将不同的值传递给不同的函数

Python 如何一次将不同的值传递给不同的函数,python,function,user-interface,window,maya,Python,Function,User Interface,Window,Maya,我有一个问题…我正在用Python编写一个脚本…我有一些滑块可以插入值..但是我想让一些值转到一个函数,一些其他函数…这是一个脚本,允许我在另一个函数中传递所有函数…在注释行中,我认为它可以满足我的需要,但它没有 import maya.cmds as cmds #def function1(value): def function1(value1,value2): print(value1) def function2(value): print(value) def c

我有一个问题…我正在用Python编写一个脚本…我有一些滑块可以插入值..但是我想让一些值转到一个函数,一些其他函数…这是一个脚本,允许我在另一个函数中传递所有函数…在注释行中,我认为它可以满足我的需要,但它没有

import maya.cmds as cmds

#def function1(value):
def function1(value1,value2):
    print(value1)

def function2(value):
    print(value)

def createUI(): 
    cmds.window("Window")
    cmds.columnLayout( adjustableColumn=True )
    value1 = cmds.intSliderGrp(label='number of moons', minValue=4, maxValue=20, value=12, field=True)
    value2 = cmds.intSliderGrp(label='Distance from parent to child', minValue=5, maxValue=40, value=20, field=True)

    #cmds.button(label = "OK", command = lambda *args: function1(cmds.intSliderGrp(value1, query=True, value=True)),function2(cmds.intSliderGrp(value2, query=True, value=True)))
    cmds.button(label = "OK", command = lambda *args: function1(cmds.intSliderGrp(value1, query=True, value=True), cmds.intSliderGrp(value2, query=True, value=True)))
    cmds.showWindow()

createUI()
import maya.cmds as cmds
from functools import partial

# Dictionnary to store the ui important variables
uiDic = {}

#def function1(value):
def function1(value1,value2):
    print(value1)
    print(value2)
# another normal function
def function2(value):
    print(value)

# save the slider value to the dic
def setSliderUiDic(sliderName, *args):
    entryName = '{}_value'.format(sliderName)
    uiDic[entryName] = getSlider(sliderName)

# get any slider value (in order to refresh)
def getSlider(nameCtrl):
    value = cmds.intSliderGrp(nameCtrl, query=True, value=True)
    return value

# create a def that combine multiple function to ui purposes
def ui_func(*args):
    slider1Value = uiDic['{0}_value'.format(uiDic['value1'])]
    slider2Value = uiDic['{0}_value'.format(uiDic['value2'])]
    function1(slider1Value, slider2Value)
    function2(slider1Value)

def createUI(): 
    #windowtest
    if cmds.window("wintest", q=True, ex=True):
        cmds.deleteUI("wintest")
    cmds.window("wintest")
    #layout
    cmds.columnLayout( adjustableColumn=True )
    #create the slider and store it to dic
    uiDic['value1'] = cmds.intSliderGrp(label='number of moons', minValue=4, maxValue=20, value=12, field=True)
    # Add a function to update the value of the slider
    cmds.intSliderGrp(uiDic['value1'], e=True, cc=partial(setSliderUiDic, uiDic['value1']))
    # Store the default value
    setSliderUiDic(uiDic['value1'])

    #Do the same thing to slider 2
    uiDic['value2'] = cmds.intSliderGrp(label='Distance from parent to child', minValue=5, maxValue=40, value=20, field=True)
    cmds.intSliderGrp(uiDic['value2'], e=True, cc=partial(setSliderUiDic, uiDic['value2']))
    setSliderUiDic(uiDic['value2'])

    # create a UI function that group multiple functions
    cmds.button(label = "OK", command = ui_func)
    cmds.showWindow()

createUI()