Menu

NOTIFICATION.SHUTDOWN not firing?

Help
dshimkoski
2012-08-30
2014-05-12
  • dshimkoski

    dshimkoski - 2012-08-30

    I'm attempting to write a session management feature. The basic idea:

    sessionFile = None
    def saveSession():
        print "saving session: %s" % (sessionFile)
        notepad.saveCurrentSession(sessionFile)
    def ready(args):
        global sessionFile
        console.show()
        sessionFile = notepad.getCurrentFilename()
        ext = os.path.splitext(sessionFile)[1][1:]
        if ext == "npp":
            files = editor.getText().split("\n")
            notepad.close()
            print "opening session: %s" % (sessionFile)
            notepad.open(files[0])
            notepad.callback(saveSession, [NOTIFICATION.SHUTDOWN])
    notepad.callback(ready, [NOTIFICATION.READY])
    

    I'm expecting the shutdown notification to fire when the main window is closed, but it's not happening for some reason.

    Any idea why this isn't working?

    Thanks,
    Denny

     
  • Dave Brotherstone

    NOTIFICATION.READY is never sent - that happens just before Python is initialised.

    What you need to do is add the script to your startup.py (or import it), and run the ready() directly.

    Note that print in a script will write into the current document. Use console.write() to write to the console.

    I'm not 100% sure that NOTIFICATION.SHUTDOWN works exactly as it should. Post an update here if this doesn't appear to get called.

     
  • Jim

    Jim - 2014-05-12
     

Log in to post a comment.