Thanks for the response. I don't think that will help me though. Maybe I don't understand what you mean.
In this case, I'm running a series of operations using third-party tool in Maya, and each operation takes 2-30 seconds to complete. The operations have to be run in Maya's main thread. After each operation, I can call QtCore.QCoreApplication.processEvents() and respond if my Cancel button was clicked, and that works. However, at the time the user actually clicks on the Cancel button, the GUI doesn't respond at all - ie the button doesn't depress, and I can't display a "cancelling..." type message. Because Maya and Qt are both running in the same thread, the first Qt knows of the click is after Maya returns from its operation. On Tuesday, 24 March 2015 12:46:50 UTC+11, Justin Israel wrote: > > 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] > <javascript:>> 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] <javascript:>. >> 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/f5e38afa-5232-42cc-940e-a1f42d5e6477%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
