Passing variables in python from radio buttons
Question: I want to set values depends on the selected radio button and to use that
values in other function. Whatever i try, i always get the same answer

# NameError: global name 'tX' is not defined #

    
    
    import maya.cmds as cmds
    from functools import partial
    
    winID='MSDKID'
    
    def init(*args):
        print tX
        print tY
        print tZ
        print rX
        print rY
        print rZ    
        return 
    
    def prozor():
    
        if cmds.window(winID, exists = True):
                cmds.deleteUI(winID);
        cmds.window()
        cmds.columnLayout( adjustableColumn=True, rowSpacing=10 )
        cmds.button(label = "Init")
        cmds.button(label = "MirrorSDK",command=init)
        cmds.setParent( '..' )
        cmds.setParent( '..' )
    
        cmds.frameLayout( label='Position' )
        cmds.columnLayout()
        collection2 = cmds.radioCollection()
        RButton0 = cmds.radioButton( label='Behavior' )
        RButton1 = cmds.radioButton( label='Orientation' )
        cmds.button(l='Apply', command = partial(script,RButton0,RButton1,))
        cmds.setParent( '..' )
        cmds.setParent( '..' ) 
        print script(RButton0,RButton1)
        cmds.showWindow()
    
    def script(RButton0,RButton1,*_cb_val):
        X = 0
        rb0 = cmds.radioButton(RButton0, q = True, sl = True)
        rb1 = cmds.radioButton(RButton1,q = True, sl = True)
        if (rb0 == True):
            tX = -1
            tY = -1
            tZ = -1
    
            rX = 1
            rY = 1
            rZ = 1
    
        if (rb1 == True):
            tX = -1
            tY = 1
            tZ = 1 
            rX = 1
            rY = -1
            rZ = -1
            return tX,tY,tZ,rX,rY,rZ        
    
    prozor()  
    


Answer: The variables you are defining in `script()` are local to that function. The
other functions don't see them.

If you need multiple UI elements to share data, you'll probably need to create
a class to let them share variables. Some reference
[here](http://theodox.github.io/2014/maya_callbacks_cheat_sheet) and
[here](http://tech-artists.org/forum/showthread.php?3292-maya-python-UI-
acessing-controls-from-external-functions)

