Recently, I used those two methods in a class creating an ui.
Maybe you could use them to get started...
RegisterCallbacks should be passed the string value of your main ui window
I guess, even if it should work with any other type of ui element.
import maya.OpenMayaUI as omUIimport maya.OpenMaya as om
def theCallback(*args):
pass
def registerCallbacks(attachCbToThisUi):
createdCallBacks = []
createdCallBacks.append(om.MSceneMessage.addCallback(om.MSceneMessage.kAfterCreateReference,
theCallback, 'someData'))
createdCallBacks.append(om.MSceneMessage.addCallback(om.MSceneMessage.kAfterLoadReference,
theCallback, 'someData'))
createdCallBacks.append(om.MSceneMessage.addCallback(om.MSceneMessage.kAfterRemoveReference,
theCallback, 'someData'))
createdCallBacks.append(om.MSceneMessage.addCallback(om.MSceneMessage.kAfterUnloadReference,
theCallback, 'someData'))
omUI.MUiMessage.addUiDeletedCallback(attachCbToThisUi,
removeCallbacks, createdCallBacks)
return createdCallBacks
def removeCallbacks(cbIdsToRemove):
for cbId in cbIdsToRemove:
om.MMessage.removeCallback(cbId)
2015-12-03 17:06 GMT+01:00 Kyle Burris <[email protected]>:
> I'm trying to trigger a UI refresh function when a referenced file is
> loaded and unloaded. The 'PostSceneRead' scriptJob event works great for
> loading, but I can't find a way to trigger a command when a reference is
> unloaded. I tired putting attributeChanged on a bunch of different attrs on
> the referenceNode, but that didn't work.
>
> I stumbled on something online where someone was suggesting taking an
> attribute from a referenced node and then attaching a scriptJob to it with
> the attributeDeleted event. However since the files might not share any
> common attributes I'd have to randomly select a node.attr per referenced
> file and attach a scriptJob to it. That approach could work but seems
> clunky to me.
>
> Anyone have any ideas?
>
> Thanks,
> Kyle
>
> --
> 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/e1193bf7-8016-40c0-a2a8-33f2c132fe1e%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/e1193bf7-8016-40c0-a2a8-33f2c132fe1e%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/CAD65uqk9uxEfLK91p%3DaF6MxUFTw-z57PcOqQvkrOf7V6Hi%2BFwA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.