I have been working on a tool that will display attributes based on the selection in the UI
I have been digging deep trying to access / change the UI of a channelBox UI element
but it updates the UI through callbacks maybe?
Getting the meta objects of all the children and listing their class name gave me custom class names
import maya.OpenMayaUI as mui
import shiboken2
from PySide2 import QtWidgets
# example from cmds.channelBox()
cmds.window()
cmds.formLayout( 'x' )
control = cmds.channelBox( 'dave' )
cmds.formLayout( 'x', e=True, af=(('dave', 'top', 0), ('dave', 'left', 0), ('dave', 'right', 0), ('dave', 'bottom', 0)))
cmds.showWindow()
ptr = mui.MQtUtil.findControl(control)
widget = shiboken2.wrapInstance(long(ptr), QtWidgets.QWidget)
for child in widget.children():
meta = child.metaObject()
print type(child)
print meta.className()
output:
<type 'PySide2.QtWidgets.QWidget'>
QWidget
<type 'PySide2.QtWidgets.QWidget'>
QWidget
<type 'PySide2.QtWidgets.QStyledItemDelegate'>
QStyledItemDelegate
<type 'PySide2.QtWidgets.QHeaderView'>
QHeaderView
<type 'PySide2.QtWidgets.QHeaderView'>
QHeaderView
<type 'PySide2.QtWidgets.QAbstractButton'>
QTableCornerButton
<type 'PySide2.QtCore.QItemSelectionModel'>
QItemSelectionModel
<type 'PySide2.QtWidgets.QTableView'>
QmayaTableView
<type 'PySide2.QtWidgets.QItemDelegate'>
QmayaItemDelegate
<type 'PySide2.QtWidgets.QWidget'>
QWidget
QmayaTableView and QmayaItemDelegate are the custom classes used for displaying the control boxes
Tried looking to those class names internally and inside the maya installation folder, but no luck there
My guess is that they are C++ class not wrapped in Python?
If anyone has alternative ideas those would be welcome ๐
I just want to avoid writing code for something that already exists in Maya
Thanks in advance
I have been working on a tool that will display attributes based on the selection in the UI
I have been digging deep trying to access / change the UI of a channelBox UI element
but it updates the UI through callbacks maybe?
Getting the meta objects of all the children and listing their class name gave me custom class names
import maya.OpenMayaUI as mui
import shiboken2
from PySide2 import QtWidgets
# example from cmds.channelBox()
cmds.window()
cmds.formLayout( 'x' )
control = cmds.channelBox( 'dave' )
cmds.formLayout( 'x', e=True, af=(('dave', 'top', 0), ('dave', 'left', 0), ('dave', 'right', 0), ('dave', 'bottom', 0)))
cmds.showWindow()
ptr = mui.MQtUtil.findControl(control)
widget = shiboken2.wrapInstance(long(ptr), QtWidgets.QWidget)
for child in widget.children():
meta = child.metaObject()
print type(child)
print meta.className()
output:
<type 'PySide2.QtWidgets.QWidget'>
QWidget
<type 'PySide2.QtWidgets.QWidget'>
QWidget
<type 'PySide2.QtWidgets.QStyledItemDelegate'>
QStyledItemDelegate
<type 'PySide2.QtWidgets.QHeaderView'>
QHeaderView
<type 'PySide2.QtWidgets.QHeaderView'>
QHeaderView
<type 'PySide2.QtWidgets.QAbstractButton'>
QTableCornerButton
<type 'PySide2.QtCore.QItemSelectionModel'>
QItemSelectionModel
<type 'PySide2.QtWidgets.QTableView'>
QmayaTableView
<type 'PySide2.QtWidgets.QItemDelegate'>
QmayaItemDelegate
<type 'PySide2.QtWidgets.QWidget'>
QWidget
QmayaTableView and QmayaItemDelegate are the custom classes used for displaying the control boxes
Tried looking to those class names internally and inside the maya installation folder, but no luck there
My guess is that they are C++ class not wrapped in Python?
If anyone has alternative ideas those would be welcome ๐
I just want to avoid writing code for something that already exists in Maya
Thanks in advance
Can't find what you're looking for? Ask the community or share your knowledge.