hieristkarl
Jan 12, 2019 - 20:15
Hello,
I have a background task which looks for an event, but this should only happen while one view is open.
Is there a way to determine if a certain view is closed?
Hello,
I have a background task which looks for an event, but this should only happen while one view is open.
Is there a way to determine if a certain view is closed?
you could setup a custom view and overwrite the will_close method, maybe you also like to know when the view is fully loaded...
I have copied the appropiate code from the docs http://omz-software.com/pythonista/docs/ios/ui.html for you
import ui
class MyView (ui.View):
def did_load(self):
# This will be called when a view has been fully loaded from a UI file.
pass
def will_close(self):
# This will be called when a presented view is about to be dismissed.
# You might want to save data here.
pass
For background threads, check your view.on_screen in your thread's callback.
@JonB thanks, that’s what I was searching for.
By the way, if you are just trying to pause something until the view closes, you would use wait_modal instead.