按下按钮时调用 class 中的函数?在 python

calling a function in a class when button is pressed? in python

我 运行 在尝试调用函数时遇到了一些错误。我有一个按钮,当按下时应该打印快照。

#code for button
cmds.button(label='FK 2 IK', command = 'Fk2Ik()', width=100)
cmds.button(label='IK 2 FK',  command = Snapping.Ik2Fk(), width=100)
cmds.setParent('..')
cmds.separator(h=5, style = 'none')
cmds.separator(h=5)




#code for function
class Snapping(self):   

    def Ik2Fk(self):
        print "Snapped"


'''
the error I get is this

# Error: TypeError: file <maya console> line 119: unbound method Ik2Fk() must be called with Snapping instance as first argument (got nothing instead) #
class Snapping(self):   
    @staticmethod
    def Ik2Fk():
        print "Snapped"

cmds.button(label='FK 2 IK', command = 'Fk2Ik()', width=100)
cmds.button(label='IK 2 FK',  command = Snapping.Ik2Fk, width=100)
cmds.setParent('..')
cmds.separator(h=5, style = 'none')
cmds.separator(h=5)