omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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

    Pythonista
    2
    3
    2185
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • skrohmer
      skrohmer last edited by

      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

      1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by

        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.

        1 Reply Last reply Reply Quote 2
        • skrohmer
          skrohmer last edited by

          Thanks, I will try this. I was so focused on the word 'destructor' that I missed them.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors