You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I have a slider for my gui, but I don't want it to fire immediately until it stops moving. My quick solution to this is to have the app wait half a second before executing it, and cancel that request if a new one comes in. The downside to doing this method is that the console will spit out the warning Could not cancel function - it doesnt exist, it may have already run every time I start moving the slider.
defslider_changed_for_real():
print('The new value is: '+str(slider.value))
defslider_changed():
slider.cancel(slider_changed_for_real) # Throws a warning if `slider_changed_for_real` isn't scheduled.slider.after(500, slider_changed_for_real)
Describe the solution you'd like
I'd like an optional parameter to cancel that would not print the warning if set to True (defaults to False).
defcancel(self, function, ignoreWarning=False):
"""Cancel the scheduled `function` calls."""iffunctioninself._callback.keys():
callback_id=self._callback[function][0]
self.tk.after_cancel(callback_id)
self._callback.pop(function)
elifnotignoreWarning:
utils.error_format("Could not cancel function - it doesnt exist, it may have already run")
Either that or introduce a new method that returns a boolean if a function is scheduled or not.
defis_scheduled(self, function):
"""Returns True if the function has been scheduled."""returnfunctioninself._callback.keys()
So as I'm writing this I figured out I can just do this to "solve" my problem:
defslider_changed():
# Only cancel if the function is scheduled. Avoids the warning.ifslider_changed_for_realinslider._callback.keys():
slider.cancel(slider_changed_for_real)
slider.after(500, slider_changed_for_real)
Not a fan of having to use a variable that is supposed to be private, so I'm still gonna advocate for an official solution. :)
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I have a slider for my gui, but I don't want it to fire immediately until it stops moving. My quick solution to this is to have the app wait half a second before executing it, and cancel that request if a new one comes in. The downside to doing this method is that the console will spit out the warning
Could not cancel function - it doesnt exist, it may have already run
every time I start moving the slider.Describe the solution you'd like
I'd like an optional parameter to
cancel
that would not print the warning if set to True (defaults to False).Either that or introduce a new method that returns a boolean if a function is scheduled or not.
So as I'm writing this I figured out I can just do this to "solve" my problem:
Not a fan of having to use a variable that is supposed to be private, so I'm still gonna advocate for an official solution. :)
The text was updated successfully, but these errors were encountered: