p = pm.getPanel(scriptType='hyperShadePanel')
assert len(p) == 1
hypershade = p[0].getControl() mainForm = pm.layout(hypershade, query=True, childArray=True)[0]
assert mainForm.lower() == 'mainform'Hi,four questions below...I'm looking to add some buttons and menus to the Hypershade. I'm new to working with the existing Maya UI so maybe I'm doing this all wrong.This is the best way I've found to get the Hypershade window:p = pm.getPanel(scriptType='hyperShadePanel')
assert len(p) == 1
hypershade = p[0].getControl()I'd read that the Maya UI was all Qt now, but this method gets me a pymel.core.uitypes.Panel. Is Hypershade built in Qt?
To get individual layouts, the only way I've found is to know the structure in advance. For example:mainForm = pm.layout(hypershade, query=True, childArray=True)[0]
assert mainForm.lower() == 'mainform'
That all seems pretty delicate. Is there a more robust way to get (for example) the toolbar at the top of Hypershade?
import maya.OpenMayaUI as mui
from PySide import QtGui, QtCore
import shiboken
p = cmds.getPanel(scriptType='hyperShadePanel')
ptr = mui.MQtUtil.findControl(p[0])
dlg = shiboken.wrapInstance(ptr, QtGui.QDialog)
dlg.findChildren(QtGui.QMenuBar)
To make all that actually work, I would need to do it each time the Hypershade opens. Can I get a callback when the Hypershade window is opened? I can't see any MMessage or callback that would tell me.
And finally, is there any good help on MMessage anywhere? The Autodesk help is a decent reference, if you already know what you can do.Thanks,Boon
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/460c6e34-1e31-45d2-913f-31d1dde1f880%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
class HyperShadeEventFilter(QtCore.QObject): def eventFilter(self, object, event): if event.type() == QtCore.QEvent.Type.ChildPolished: child = event.child() if 'hyperShadePanel' in child.objectName(): doStuff() elif event.type() == QtCore.QEvent.Type.ChildRemoved: child = event.child() if 'hyperShadePanel' in child.objectName(): doStuff()To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
ptr = mui.MQtUtil.mainWindow()
mainWin = shiboken.wrapInstance(long(ptr), QtGui.QWidget)
mainWin.installEventFilter(self)
import maya.OpenMayaUI as mui
import shiboken
from PySide import QtGui
from PySide import QtCore
class HyperShadeEventFilter(QtCore.QObject):
def __init__(self):
ptr = mui.MQtUtil.mainWindow()
mainWin = shiboken.wrapInstance(long(ptr), QtGui.QWidget)
mainWin.installEventFilter(self)
def eventFilter(self, object, event):
if event.type() == QtCore.QEvent.Type.ChildPolished:
child = event.child()
if 'renderViewWindow' in child.objectName():
print 'OPEN'
elif event.type() == QtCore.QEvent.Type.ChildRemoved:
child = event.child()
if 'renderViewWindow' in child.objectName():
print 'CLOSE'
HyperShadeEventFilter()To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/78a82075-e02f-48a4-8c3c-547c27ba4a77%40googlegroups.com.
// Error: '__init__' method of object's base class (HyperShadeEventFilter) not called.
# Traceback (most recent call last):
# File "<maya console>", line 22, in <module>
# File "<maya console>", line 10, in __init__
# RuntimeError: '__init__' method of object's base class (HyperShadeEventFilter) not called. //To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/460c6e34-1e31-45d2-913f-31d1dde1f880%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
You’ll need to call the __init__ method of the object’s baseclass.
def __init__(self):
super(HyperShadeEventFilter, self).__init__()
ptr = mui.MQtUtil.mainWindow()
mainWin = shiboken.wrapInstance(long(ptr), QtGui.QWidget)
mainWin.installEventFilter(self)
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/92306db8-5990-4b51-979c-bdf5c50f5af8%40googlegroups.com.To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/92306db8-5990-4b51-979c-bdf5c50f5af8%40googlegroups.com.
You’ll need to call the __init__ method of the object’s baseclass.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCCV3SSdC-fK_U%2BOUZm%2ByogFuV40bd6Y-HkxyTbBm6GqQ%40mail.gmail.com.
class HyperShadeEventFilter(QtCore.QObject):
def __init__(self):
super(HyperShadeEventFilter, self).__init__()
ptr = mui.MQtUtil.mainWindow()
mainWin = shiboken.wrapInstance(long(ptr), QtGui.QWidget)
mainWin.installEventFilter(self)
def eventFilter(self, object, event):
print event.type()
if event.type() == event.Type.ChildPolished:
child = event.child()
print child.objectName()
if 'hyperShadePanel' in child.objectName():
print 'OPEN'
elif event.type() == event.Type.ChildRemoved:
child = event.child()
if 'hyperShadePanel' in child.objectName():
print 'CLOSE'
HyperShadeEventFilter()--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/45b59ddf-16ce-4434-a356-0d1179bb6114%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODwawJi0dKjmBa%3DqGnwgffbzTs9MPXX1MO9g1pQAPNodA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3jG3-d%2BOGv8aoNFwTGv3UwZZFg4%2Byx2J2bR0da1aYs5A%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/45b59ddf-16ce-4434-a356-0d1179bb6114%40googlegroups.com.
----
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
Ok, also make sure that you’re keeping the instance of the eventfilter alive at run-time.
For example, this:
def __init__(self):
filter = MyEventFilter()
self.installEventFilter(filter)
Will cause filter to get picked up by garbage collection before it gets a chance to do anything. One way is to add it as a member to the class.
def __init__(self):
self.filter = MyEventFilter()
self.installEventFilter(self.filter)
Do post the entire code if you can, otherwise I can only guess.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/c53c462e-d967-425c-97a3-e4fd15a1ce5f%40googlegroups.com.
import maya.OpenMayaUI as mui
import shiboken
from PySide import QtGui
from PySide import QtCore
class HyperShadeEventFilter(QtCore.QObject):
def __init__(self):
super(HyperShadeEventFilter, self).__init__()
ptr = mui.MQtUtil.mainWindow()
self.Handler = Handler()
mainWin = shiboken.wrapInstance(long(ptr), QtGui.QWidget)
mainWin.installEventFilter(self.Handler)
class Handler(QtCore.QObject):
def eventFilter(self, obj, event):
if event.type() == event.ChildPolished:
print event.type()
child = event.child()
print child.objectName()
if 'hyperShadePanel' in child.objectName():
print 'OPEN'
elif event.type() == event.ChildRemoved:
print event.type()
child = event.child()
if 'hyperShadePanel' in child.objectName():
print 'CLOSE'
return super(Handler, self).eventFilter(obj, event)
x = HyperShadeEventFilter()To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/45b59ddf-16ce-4434-a356-0d1179bb6114%40googlegroups.com.
--
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODwawJi0dKjmBa%3DqGnwgffbzTs9MPXX1MO9g1pQAPNodA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/c53c462e-d967-425c-97a3-e4fd15a1ce5f%40googlegroups.com.
You’re very welcome, but something is not right.
Handler is the event filter, yet HyperShadeEventFilter is named “eventfilter”. What is HyperShadeEventFilter doing? You can remove it, and instead do this.
eventfilter = Handler()
mainWin = shiboken.wrapInstance(long(ptr), QtGui.QWidget)
mainWin.installEventFilter(eventfilter)
When run from Maya, Maya will keep eventfilter alive, as it does with all local variables. In a standalone application, this would probably have to be wr
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/2ff63179-b3f7-4038-9a06-b7cb2a29c679%40googlegroups.com.To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/c53c462e-d967-425c-97a3-e4fd15a1ce5f%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/2ff63179-b3f7-4038-9a06-b7cb2a29c679%40googlegroups.com.
from PySide import QtCoreevent = QtCore.QEvent(QtCore.QEvent.ChildPolished)QtCore.QEvent.Type.ChildPolished == QtCore.QEvent.ChildPolished # Result: True # event.type() == event.ChildPolished # Result: True #
event.ChildPolished == QtCore.QEvent.ChildPolished # Result: True #
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/45b59ddf-16ce-4434-a356-0d1179bb6114%40googlegroups.com.
----
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/bf5fd23f-a645-4d21-8dfa-f51c2b7e8c70%40googlegroups.com.