I’m Sub-classing a QToolButton and I’m wondering if it’s possible query the function the tool is connected to.
My end goal is to kind of re-create a Right-Click Menu on a button with an “Edit cmd” and “Open cmd” similar to Maya’s shelf button. I have some functions to get the script and line numbers but it’s a matter of inspecting the correct function and not the menu function. That way when I Right-Click on “Open cmd” it will launch a say sublime or Notepad++ to the line number of the function the button is connected to. Possible?
Well, not the Action of the menu itself but the connected command of the button.
So if I would do a Right-Click menu with Edit Cmd it would grab the buttons function.
Grab my_command and tell me the file location and line number
self.someButton.clicked.connect(self.my_command)
line #45 in myTool.py
Yes, if I inspect the Action of the menu then it just tells me the function of the menu which works fine but I’m after the button itself. I guess trying to inspect a bit deeper.
Hope I’m making sense.
Quick Update:
In my Right-Click Menu in my Button Class I have I did a quick print of my object:
print self.dict
In that dict is a clicked Signal Instance
{‘fontBold’: True, ‘clicked’, <PySide.QtCore.SignalInstance object at 0x000000004B603E10>, …}
Might be able to get a that.
I would probably create a custom “command” class to hold the function and a custom button class that consumes a “command” class. then the other aspects of the button can query the “command” class.