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
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.
This does not appear to be called.
https://gist.github.com/jimfoltz/11332363#file-sudb-py-L37
Log in to post a comment.
I'm attempting to write a session management feature. The basic idea:
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
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.
This does not appear to be called.
https://gist.github.com/jimfoltz/11332363#file-sudb-py-L37