On Tue, 24 Mar 2015 8:31 PM Marcus Ottosson <[email protected]> wrote:

There’s a few different ways of doing heavy processing in Maya, some might
allow you to keep the UI responsive whilst others might not.

For example, if the heavy processing occurs between many frames, like a
cache or playback of a heavy rig, then it looks like Qt does process events
inbetween frames which would allow you to keep the UI moderately responsive
- as in, not during a frame, but at least with similar lag to the viewport
- and have you cancel-button do something like this.

for frame in cache_frames(): if not isrunning: break

Where isrunning is toggled by your cancel button.

On the other hand, if the heavy processing takes place in pure Python, then
you could safely thread it and allow Qt to process events in the main
thread on it’s own, but I take it this isn’t your case.

Lastly, the heavy processing could occur within a single Maya command; like
a long-running simulation or billion poly subdivision. In this case, it
looks like you’re out of luck as Maya doesn’t seem to let Qt breathe until
it’s completely finished. :(

*IPC*

For such a simple use-case, what I’m about to suggest is probably not worth
it, but perhaps something to think about for your next project; a
responsive UI is very important to the user experience, after all.

The above is just as you explained it; two event-loops fighting for
attention. What you could do instead is put Qt in it’s own process and do
communication via IPC. That way, they could both process events in their
own main threads and regardless of how busy one gets, it will have no
effect on the other.

The downside of course is having to manage IPC to begin with. RPC might
give you the more similar experience of what it’s like without IPC and
there are libraries out there to facilitate this such as Pyro
<https://pythonhosted.org/Pyro4/>, RPyC
<https://rpyc.readthedocs.org/en/latest/> or PyRPC
<https://github.com/justinfx/pyRpc> (by Justin, woh!).


My PyRPC works but was really more of an experiment I did when I first
played with ZeroMQ.

If you are on linux, there is also dbus, which is a builtin message service
so you can discover and communicate between apps. And also the basic
command port if you just want a simple way to tell Maya to do stuff.


​

-- 
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/CAFRtmOAQzcePHpsgmvNGBgA4LAL8HDKzZWA5JFu707HpNo_%3Dsw%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAQzcePHpsgmvNGBgA4LAL8HDKzZWA5JFu707HpNo_%3Dsw%40mail.gmail.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/CAPGFgA0cHD0PS85EW7%2B%3DCEGeqRGnxTq2ReY_NPeQkD64P0W_qg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to