If your goal is to keep your GUI reacting quickly, you can defer the call
to the event loop. This will allow your button to fully click. Then the
callback will run when control returns to Maya's event loop:

maya.utils.executeDeferred()

Ideally you are doing as much heavy lifting as you are able to to, in extra
threads. But in the case where things must run in the main gui thread, your
best bet is to defer them until after your gui can finish responding to the
user interaction.

On Tue, Mar 24, 2015 at 1:57 PM Michael Boon <[email protected]> wrote:

> Hi,
>
> I have a few PySide tools that are multi-threaded and in general they work
> well. However, I can't figure out how to correctly make Maya do complex
> operations while keeping my Qt GUI responsive. Both systems insist on only
> being run from the main thread.
>
> The Qt documentation <http://doc-snapshots.qt.io/4.8/thread-basics.html>
> says "The Qt GUI must run in this [the main] thread."
> And the Maya documentation
> <http://help.autodesk.com/view/MAYAUL/2015/ENU/?guid=Python_Python_and_threading>
> says "Maya commands throw an exception if they are called outside the
> main thread"
>
> Is there a good way around this?
>
> (Really all I want is to have a cancel button that will react immediately.)
>
> 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/e74b8d33-5db7-44f1-a58c-65ba549aaafb%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/e74b8d33-5db7-44f1-a58c-65ba549aaafb%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/CAPGFgA08b%3DS6xiTYOv_QCNuRoPGpewWF9%3Dt%2BqT4gbQTdKSeSzg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to