On 16/09/2014 6:06 AM, "damon shelton" <[email protected]> wrote: > > These should be fine. The thing to look out for is what you are actually doing each time the event triggers your code. sometimes triggers can happen faster than you like and you can then use a qtimer to limit the minimum amount of time before a function can actually run again once it is triggered. > > scriptJob sends event which triggers your qtimer.start which executes your function. **tip: QTimer should be singleShot=True >
I use this trick often, to delay the response of actions until they stop. Like when someone is typing in a text field and I don't want to trigger expensive refreshes on every character they type. So their typing only calls start() on a single shot qtimer. When they finally stop typing, the timer stops getting reset and triggers. There is one other variation of this approach that I use as well. If the action that triggers the timer happens often, then there are circumstances where the previous approach may not be the behaviour you want. You may not want your trigger to be reset indefinitely until the source action stops, but rather to have the action fire immediately, but ignore future triggers for a "cool down" period. The variation is to let the source action directly trigger your function, but to use isActive() on the single shot qtimer to see if it is already running, and if so, you bail. Otherwise you do your work and start the timer. Subsequent triggers again will bail while that timer is active. Just don't connect the timer trigger to anything. > On Mon, Sep 15, 2014 at 11:00 AM, <[email protected]> wrote: >> >> will I see any performance hit while they're running, or are they fairly gentle? >> >> sorry - this is all new to me ;) >> >> Kev >> >> -- >> 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/5d021b7a-2ddd-4885-a667-c18f4bbc9327%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/CAM9RXoK%2BWG08rF%2BrL9GZEi_3kVtm4CF56Vi9gEw%3DnQnNgS7LDQ%40mail.gmail.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/CAPGFgA2fP6qoxkHTxF6z70ja6RCyubyLd2aCeOgxJW3mg1SRZw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
