Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Scene destructor
-
Hello Pythonista friends,
Me again ;-) with a simple question which could not be answered by the documentation: Is there any kind of useable destructor for a Scene object? When terminating the program I would like to save some data which is created dynamically during the runtime and as I see for the moment the nicest solution would be a member function within my class (the class is derived from scene.Scene). Sometimes I have used
__del__
in other classes but it does not seem to work in a stable way. Is there a function within Scene which is called when the scene is closed and all nodes are still available?Stefan
-
From the scene docs, there are a few methods which you can define:
Scene.pause()
Gets called automatically when the home button is pressed while a scene is running. You can override this to save persistent state for example. The default implementation does nothing.Scene.resume()
Gets called automatically when a scene is resumed (after being sent to the background with the home button). The default implementation does nothing.Scene.stop()
Gets called automatically when a scene is stopped (by tapping the “x” button). You can override this to save persistent state. The default implementation does nothing. -
Thanks, I will try this. I was so focused on the word 'destructor' that I missed them.