Lets say you want to add some custom buttons to the Outliner in Maya’s vanilla Graph Editor. You could do this by getting the workspace control and wrapping it in a QWidget class.
But in order to do that, you need to know the name of the workspace control. In Maya 2018, the name is “graphEditor1OutlineEdSlave”, and you’d get a variable for editing it by doing
But this name doesnt work in Maya 2023. ptr is None, so I need to find whatever the new name is. How do you get the string “graphEditor1OutlineEdSlave” in the first place? Is there a way that I can run a script that prints the name of any UI element I click on?
In essence, the solution is to start from the top-level widget of Maya, and iterate through the children to collect information.
Here are some ideas.
Maya 2023:
from PySide2 import QtWidgets
x = dict((w.objectName(), w) for w in QtWidgets.QApplication.allWidgets())
y = [name for (name, widget) in x.items()]
y.sort()
for name in y:
print(name)
This list has some unclear names, such as iconTextButton1 - iconTextButton49, but it gave me plenty of other descriptive names. to get the widget, you just access the dict you made.
Another thing you could do is:
from PySide2 import QtWidgets
x = dict((w.objectName(), w) for w in QtWidgets.QApplication.allWidgets())
for name, widget in x:
widget.setToolTip(name)
Not all the tooltips get updated, but you can hover the mouse over a lot of them and see the name. For example, the default location for the timeline slider widget is inside of frameLayout2. Who would’ve ever guessed that!
Another thing you could do is create a new QT TreeView widget that builds the entire widget heirarchy, and each entry will fire an event on click to make its direct parent window have focus or something.