-
Notifications
You must be signed in to change notification settings - Fork 786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Proper" way of pausing timers when switching MODES? #5189
Comments
How about putting the following in your timer functions? if not self.screen.is_active:
return |
Thanks @willmcgugan ! I'll give this a go later this week - thank you for the suggestion! |
This worked perfectly. Thanks @willmcgugan |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Spurred on by a comment in #3405 ...
This would be interesting to me - I am trying to manually pause timers when switching screens as my timers control the updates to active screens based on an elapsed timeframe, e.g. when screen 1 is active, update x once every 5 sec.
I have a class TimedScreen that provides functions to track, initiate, and pause/resume timers. It uses the ScreenSuspend and ScreenResume events. When switching screens (via MODES), I attempt to pause the screen's timers, but the events are still firing. However, the messages are being relayed so it seems the actual pause()/resume() functions should be being called
You can see a MRE class that you can include in a test exhibiting the issue here: https://github.com/freqtrade/ftui/blob/main/ftui/widgets/timed_screen.py
Timers are added to a screen via on_mount(), as shown here: https://github.com/freqtrade/ftui/blob/main/ftui/screens/dashboard_screen.py#L86
The text was updated successfully, but these errors were encountered: