I read everything in and display it in a tablelist which is gridded into
a toplevel with a couple of scrollbars. (There are only a couple of
hundred rows and a couple of columns, so it's feasible to read
everything in once-and-for-all.)
When the user exits, I want to write any updates back to the database.
The embarassing thing is, I can't work out how to get notified about
application exit.
I've tried binding to <Destroy> on the toplevel.
The first thing I spotted was that my binding was trigger many times,
apparently once for each widget that was being destroyed. I worked
around this by only reacting when the toplevel was being destroyed, and
this works fine for dropping the database connection and destroying any
other temporary stuff I've created in the application. (I like to run
the script repeatedly from tkcon whilst debugging, so I want to take
care of these things explicitly.)
I tried doing the database update when the tablelist is destroyed.
Unfortunately, getting data back from a tablelist seems to be one of
those things that the manpage for bind says will fail at this point.
Hence my question - "how do I detect that an application is closing down."
Two extra constraints:
i) I'm developing this on Linux (Ubuntu 8.08) and intending
to deploy on Windows (XP), so nothing too platform-specific
if possible, please; and
ii) I'm developing with Tcl 8.6b2 and intend to deploy on Tcl
8.5, so not too many recent features if possible, pretty
please.
Many thanks,
Alan
Thank you. [wm protocol $W WM_DELETE_WINDOW {...}] does the trick nicely.
Alan