Confirm selection maya ui python

Hello!

Was wondering if there was a better way to go about doing this other than making new functions for each selection

I have 8 buttons set up like this:

form = cmds.formLayout()

tabs = cmds.tabLayout(innerMarginWidth=5, innerMarginHeight=5)

cmds.formLayout( form, edit=True, attachForm=((tabs, ‘top’, 0), (tabs, ‘left’, 0), (tabs, ‘bottom’, 0), (tabs, ‘right’, 0)) )

child1 = cmds.columnLayout(columnAttach=(‘both’, 5), columnWidth=200,adjustableColumn=True, columnAlign=“center” )

cmds.text(label = ‘Root Joint Selection’, align =‘center’)

cmds.separator(h=10, style = ‘none’)

cmds.separator(h=5)

cmds.text(label = ‘Right Arm’, align =‘center’)

tsL0 =cmds.textFieldButtonGrp(ed=False, adj=1,cal=(1,“left”),cw3=(10,100,25), cl3=(“left”,“left”,“left”) , buttonLabel=‘Select FK’,bc = ‘selectJoint()’ )

gtF0 = tsL0

cmds.separator(h=10, style = ‘none’)

And I have my functions connected to them with this:

def selectJoint():
global jointName
listJoint = cmds.ls(selection = True)
jointName = listJoint
if cmds.ls(listJoint, type=‘joint’):
cmds.textFieldButtonGrp(gtF0, edit = True, tx =’’ .join(listJoint),buttonLabel=‘IK OK’,backgroundColor = (.5,.8,.2))
cmds.textFieldButtonGrp(gtF1, edit = True, tx =’’ .join(listJoint),buttonLabel=‘FK OK’,backgroundColor = (.5,.8,.2))
cmds.textFieldButtonGrp(gtF2, edit = True, tx =’’ .join(listJoint),buttonLabel=‘IK OK’,backgroundColor = (.5,.8,.2))
cmds.textFieldButtonGrp(gtF3, edit = True, tx =’’ .join(listJoint),buttonLabel=‘FK OK’,backgroundColor = (.5,.8,.2))
cmds.textFieldButtonGrp(gtF4, edit = True, tx =’’ .join(listJoint),buttonLabel=‘IK OK’,backgroundColor = (.5,.8,.2))
cmds.textFieldButtonGrp(gtF5, edit = True, tx =’’ .join(listJoint),buttonLabel=‘FK OK’,backgroundColor = (.5,.8,.2))
cmds.textFieldButtonGrp(gtF6, edit = True, tx =’’ .join(listJoint),buttonLabel=‘IK OK’,backgroundColor = (.5,.8,.2))
cmds.textFieldButtonGrp(gtF7, edit = True, tx =’’ .join(listJoint),buttonLabel=‘FK OK’,backgroundColor = (.5,.8,.2))
else:
text = cmds.confirmDialog( title=‘Error’, message=‘Must select joint’, button=[‘OK’], defaultButton=‘Ok’ )

I know this looks ugly and right now they all change at once so I was hoping someone could assist me?