Button = Function + Arguments

In Maya, here are 3 examples to run a Function within a UI (explanation annotated to help another Animator with UI function calls):

Call a formatted string

Calling a string directly is a quick way to run a simple command with a UI. Here’s what the string would look like:

run_command_string = 'print(cmds.radioCollection("{}", query=True, select=True));'.format(COLLECTION1) button1 = cmds.button(label='Print String Command', command=run_command_string)

Call a unique function

With a unique function, it can only run the given command.

def run_code(*args,**kwargs):
    '''
    For as long as you're using maya.cmds, ALWAYS use *args and **kwargs.
    This will catch any extra attributes coming in with the Function call.

    Notice that "COLLECTION1" is in CapsLock.
    This usually means that a Variable is Global to the Code's scope.
    '''
    print(cmds.radioCollection(COLLECTION1, query=True, select=True))

Call a function with additional arguments

def run_partial_code(collection_name,*args,**kwargs):
    '''
    Use *args and **kwargs. This will catch any extra attributes coming in with the Function call.
    Using functools.partial allows you to add multiple Variables.
    So if your command had a crapload of Variables, you can call them like so:
        partial(run_partial_command, collection_name, this_fancy_var, oh_look_ma, i_can_fly)
    And it'll be the same as running:
        run_partial_command(collection_name, this_fancy_var, oh_look_ma, i_can_fly)
    '''
    print(cmds.radioCollection(collection_name, query=True, select=True))

Full Sample Code

  from functools import partial

def run_code(collection,*args,**kwargs):
    '''
    For as long as you're using maya.cmds, ALWAYS use *args and **kwargs.
    This will catch any extra attributes coming in with the Function call.

    Notice that "COLLECTION1" is in CapsLock.
    This usually means that a Variable is Global to the Code's scope.
    '''
    print(cmds.radioCollection(COLLECTION1, query=True, select=True))

def run_partial_code(collection_name,*args,**kwargs):
    '''
    Use *args and **kwargs. This will catch any extra attributes coming in with the Function call.
    Using functools.partial allows you to add multiple Variables.
    So if your command had a crapload of Variables, you can call them like so:
        partial(run_partial_command, collection_name, this_fancy_var, oh_look_ma, i_can_fly)
    And it'll be the same as running:
        run_partial_command(collection_name, this_fancy_var, oh_look_ma, i_can_fly)
    '''
    print(cmds.radioCollection(collection_name, query=True, select=True))
    

cmds.window()
cmds.columnLayout( adjustableColumn=True, rowSpacing=10 )
cmds.frameLayout( label='Colors' )
cmds.columnLayout()
COLLECTION1 = cmds.radioCollection()
# rb1 = cmds.radioButton( label='Red' ) # This will label the new name radioButton, but not return
                                        # the appropriate name.
rb1 = cmds.radioButton( 'Red' ) # This will use "Red" to both Label the Radio Button AND call it "Red" in the background.
print(cmds.radioButton(rb1,q=1,label=1)) # Will print "Red"
print(cmds.radioButton(rb1,q=1,fullPathName=1))
# Will print something like "window12|columnLayout136|frameLayout118|columnLayout137|Red"

rb2 = cmds.radioButton( label='Blue' )
rb3 = cmds.radioButton( label='Green' )
cmds.setParent( '..' )
cmds.setParent( '..' )

cmds.radioCollection( COLLECTION1, edit=True, select=rb2 )

# Call the command as a String
run_command_string = 'print(cmds.radioCollection("{}", query=True, select=True));'.format(COLLECTION1)
button1 = cmds.button(label='Print String Command', command=run_command_string)

# Call the Function only, all Args have to be implemented in the function from the start
button2 = cmds.button(label='Print Function Command', command=run_code)

# Call the function along with Arguments, useful when using For loops to create a lot of buttons
# that use the same Function, but each button calls different Arguments.
button3 = cmds.button(label='Print Partial Command', command=partial(run_partial_code,COLLECTION1))

## Here, since you're calling the "collection", 
## you have to use the "radioCollection" command instead of the "radioButton",
## and you are querying the "select" flag to find out what is selected.
# getSelectRadioVal1 = cmds.radioCollection(COLLECTION1, query=True, select=True)


cmds.showWindow()