From aahz at pythoncraft.com Tue Sep 22 17:06:37 2009 From: aahz at pythoncraft.com (Aahz) Date: Tue, 22 Sep 2009 08:06:37 -0700 Subject: [python-advocacy] Atlanta Linux Fest Message-ID: <20090922150637.GA23329@panix.com> http://rhodesmill.org/brandon/2009/python-at-atlanta-linux-fest/ -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "I won't accept a model of the universe in which free will, omniscient gods, and atheism are simultaneously true." --M From alexander.bladh at hotmail.com Tue Sep 29 20:10:57 2009 From: alexander.bladh at hotmail.com (alexander.bladh at hotmail.com) Date: Tue, 29 Sep 2009 18:10:57 -0000 Subject: [python-advocacy] fixing shutdown event Message-ID: tk/tcl is not abele to catch WM_QUERYENDSESSION and WM_ENDSESSION tk needs to be patched ive found this patch searching around on Google "Patch: *** tkWinX.c Sat Oct 10 02:30:37 1998 --- tkWinX.c_new Fri Mar 12 11:25:00 1999 *************** *** 50,55 **** --- 50,63 ---- LPARAM lParam)); static void GetTranslatedKey _ANSI_ARGS_((XKeyEvent *xkey)); + + static void (*fd_tcl_exit_callback_function_ptr)() = NULL; + + void fd_tcl_register_exit_callback(void (*func_ptr)()) + { + fd_tcl_exit_callback_function_ptr = func_ptr; + } + /* *---------------------------------------------------------------------- * *************** *** 588,593 **** --- 596,615 ---- Tk_PointerEvent(hwnd, (short) LOWORD(lParam), (short) HIWORD(lParam)); return 1; + + case WM_QUERYENDSESSION: { + *resultPtr = 1; + return 1; + } + + case WM_ENDSESSION: { + if ( wParam == TRUE ) { + if ( fd_tcl_exit_callback_function_ptr != NULL ) { + (*fd_tcl_exit_callback_function_ptr)(); + } + } + return 1; + } case WM_CLOSE: case WM_SETFOCUS: PatchFiles: win/tkWinX.c And, you have to modify 'winmain.c' extern void fd_tcl_register_exit_callback(void (*func_ptr)()); static Tcl_Interp *YOUR_TCL_INTERPRETER; void fd_logoff_callback() { char * command = "YOUR_TCL_EXIT_PROC"; Tcl_Obj * cmdObj = Tcl_NewStringObj(command, -1); if ( Tcl_GlobalEvalObj(YOUR_TCL_INTERPRETER, cmdObj) == TCL_ERROR ) { exit(1); } } ... /* Just before calling TkMain() */ fd_tcl_register_exit_callback(fd_logoff_callback); ... YOUR_TCL_EXIT_PROC is the Tcl procedure that will get called when a logout, restart or shutdown occurs. Comments: To handle the WM_QUERYENDSESSION and WM_ENDSESSION events on Windows, we added an 'fd_tcl_register_exit_callback()' function to Tk to register a C callback function. When receiving a WM_ENDSESSION event with LogOff == TRUE (which will only happen when all running applications returned TRUE when receiving the WM_QUERYENDSESSION event) the registered function will be called. This patch currently fits our needs, but it should be generalized. We added a 'hook' to call the registered callback function, but a better solution would be to provide a new Tcl builtin on Windows to register a Tcl logout procedure." so is there anyone knowing c that can build this for phyton?? thanks for help /Alex -------------- next part -------------- An HTML attachment was scrubbed... URL: