On Mon, Mar 12, 2018, 6:42 PM Virbhadra Gupta <[email protected]> wrote:
> Hello i am trying to create one script to create blinking image button > I can change image with image or symbolButton command > But problem it i can use any loop like while maya will be stuck while loop > is running > I think we can create it using scriptjob ?? > If yes how can i do it plz can anyone get me reference > Thanks in advance!!!! > I don't see anything in scriptJob that would help with scheduling a timer function to control blinking a button. But yes you need to avoid blocking Maya's main thread. If you want a really basic loop to happen while some kind of mode is active and you want to blink a button, then you have to "pump" the main Maya thread during the loop with something like maya.utils.processIdleEvents(). Not the best solution available. If you want to stick with Maya and the python standard library only, you could maybe do this with a timer thread, and calls to maya.utils.executeInMainThreadWithResult(), which will call your blink toggle function https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/Maya/files/Python-Python-and-threading-htm.html https://docs.python.org/2/library/threading.html#timer-objects Using a thread let's you have a timer that doesn't block Maya and will make the call happen in the mail thread using executeInMainThreadWithResult. Using this particular call will make sure to block your button toggles until Maya is able to run them and not have the timer just stacking up toggles. If you want to make use of PySide you could also just do your UI work with that, and use a Qtimer or a property animation. Here is a similar answer I gave in 2012 when someone wanted to do a shakey window animation : https://groups.google.com/d/msg/python_inside_maya/LZLIGK7aKI8/EtQEjWjZGeYJ Justin > -- > 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/7cf3ab01-a5bb-4164-ba52-139e8cd34b8e%40googlegroups.com > . > 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/CAPGFgA2gw4rvFFf2uygksgofiNsAjdvjnuoDx4DwSdB2TTAqRA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
