I'm trying to get statistics on how many time a button was clicked in PySide.
Data is stored in a dictionnary, and I'd like the key to be the clicked-function name:
Example : {"myAwesomeFunc" : 15, "anotherFunc" : 4}
I start with converting my existing (Autodesk) Maya-UI with hundreds of buttons into a QObject.
Then, I list all the buttons using the findChildren(QPushButton) method and I connect to each of them my own getStats()
function, using btn.clicked.connect(getStat)
.
Doing so, the buttons will then execute two functions when clicked, the original one from the UI, and my stat function that will increment the dictionnary.
So, where I'm stuck is how can I query the original function name associated to the button's "clicked" method ?
Example:
def myAwesomeFunc():
return
btn = QtGui.QPushButton()
btn.clicked.connect(myAwesomeFunc)
And then, what I'm looking for would be something like this :
funcList = btn.clicked.getFunctions()
myFunc = funcList[0]
print myFunc.__name__
result : "myAwesomeFunc"