On Mon, Nov 3, 2014 at 1:29 PM, Michael Boon <[email protected]> wrote:

> 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?*
>

Correct. The whole UI is a bit Qt application.


>
> 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?*
>

Either way, this whole thing will be delicate, since playing with and
manipulating Maya's own application structure can be unstable. Some of the
safer things you can do are docking your own widgets, or adding to the main
menu. But if you modify temporary windows or try to rely on finding child
widgets, you are at the mercy of whatever changes Autodesk makes in the
future, or for any undocumented behaviour to occur and undo or mix up what
you do.

That being said, you can get the Qt reference to components within the
application. What you are getting so far is just the Maya native UI stuff,
that aligns with the commands/mel api. So even though the UI is in Qt, they
have an abstraction over it and maintains the compatibility of the native
UI interface, which has a more limited exposure.

Something like this would allow you to get the reference to the hypershade
dialog, and to inspect its children:

import maya.OpenMayaUI as muifrom PySide import QtGui, QtCoreimport 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.
>

I think a similar question was asked in the last week or two? Someone was
asking for a way to know when some other window was opened, to be able to
hook into it. As far as I know, there isn't an official API approach to
knowing when a specific window is opened or closed, and it might require an
event filter on the QApplication itself, to watch for QShowEvents, and then
checking the objectName()


>
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/460c6e34-1e31-45d2-913f-31d1dde1f880%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/460c6e34-1e31-45d2-913f-31d1dde1f880%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0_BYTrrEdemnsTuObvk3F6CHnfgYTSXBtWefCcSt8wvg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to