Forum Archive

View.close()

donnieh

Is there a function or action I can refer to when a view is closed after view.present()?

I want to call a function when closed. In my case, I close the view with the left blue X in the title bar.

dgelessus

I was quite certain that there was a View.will_close method, but I can't find it in the docs. Maybe I'm imagining things. Other solutions could be View.wait_modal() (which blocks execution and returns once the view is no longer visible) or adding a custom close button that calls View.close() and then runs the "cleanup" code.

JonB

will_close does work, but you have to make a custom View class.
http://omz-software.com/pythonista/docs/ios/ui.html#building-custom-views

(Edit:added reference)

ccc

See close_action() and close_button() in https://github.com/671620616/PhantomChess/blob/master/Phantom/gui_pythonista/game_view.py which creates a custom close X to allow you to hide the title bar to maximize screen real estate for your content.