Community
Maya Programming
Welcome to Autodeskโ€™s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results forย 
Showย ย onlyย  | Search instead forย 
Did you mean:ย 

Access to internal UI class or inherit from it, for channelBox

0 REPLIES 0
Reply
Message 1 of 1
Anonymous
382 Views, 0 Replies

Access to internal UI class or inherit from it, for channelBox

Anonymous
Not applicable

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

0 Likes

Access to internal UI class or inherit from it, for channelBox

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

Labels (4)
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report