exit

Python: How can I make my tkinter app exit properly?

折月煮酒 提交于 2019-12-24 01:43:27
问题 I need to know how to do this on a mac because whenever I try quitting it, I have to force quit it. Is there a proper way when the user clicks the exit button that Tkinter will exit normally? 回答1: I figured out how. I just put a simple exit() command after the main loop. 来源: https://stackoverflow.com/questions/5427875/python-how-can-i-make-my-tkinter-app-exit-properly

iOS - kill the app with a button?

删除回忆录丶 提交于 2019-12-23 23:32:39
问题 I have an app that runs for a while, but needs to be reset every day, because it's lifecycle is a bit different than most other apps. It seems that the easiest way to do this is to kill the app and re-launch it. I found a solution that kills the app when the home button is tapped: In your application's Info.plist, add a boolean key UIApplicationExitsOnSuspend with the value YES This is not something that I want to do. I need to give the user an option to kill/reset the app before it is used.

How to use SetConsoleHandler() to block exit calls

早过忘川 提交于 2019-12-23 20:56:28
问题 I know that I have to use setconsolehandler() if I want to manage console closing events. I do not know how to block the CTRL_CLOSE_EVENT . I've tried returning false/true if it catches that event, but no success Here is what I have so far (thank you Anton Gogolev!) [DllImport("Kernel32")] public static extern bool SetConsoleCtrlHandler(HandlerRoutine Handler, bool Add); public delegate bool HandlerRoutine(CtrlTypes CtrlType); public enum CtrlTypes{ CTRL_C_EVENT = 0, CTRL_BREAK_EVENT, CTRL

should we use exit in C++?

谁说胖子不能爱 提交于 2019-12-23 12:00:26
问题 According to C++ reference exit terminates the process normally, performing the regular cleanup for terminating programs. Normal program termination performs the following (in the same order): Objects associated with the current thread with thread storage duration are destroyed (C++11 only). Objects with static storage duration are destroyed (C++) and functions registered with atexit are called. All C streams (open with functions in ) are closed (and flushed, if buffered), and all files

Is sys.exit equivalent to raise SystemExit?

天涯浪子 提交于 2019-12-23 10:56:33
问题 According to the documentation on sys.exit and SystemExit, it seems that def sys.exit(return_value=None): # or return_value=0 raise SystemExit(return_value) is that correct or does sys.exit do something else before? 回答1: According to Python/sysmodule.c, raising SystemExit is all it does. static PyObject * sys_exit(PyObject *self, PyObject *args) { PyObject *exit_code = 0; if (!PyArg_UnpackTuple(args, "exit", 0, 1, &exit_code)) return NULL; /* Raise SystemExit so callers may catch it or clean

Why is sys.exit() causing a traceback?

折月煮酒 提交于 2019-12-23 10:26:44
问题 According to How to exit from Python without traceback? , calling sys.exit() in a Python script should exit silently without a traceback. import sys sys.exit(0) However, when I launch my script from the command line on Windows 7 with python -i "exit.py" , (or from Notepad++), a traceback for a SystemExit exception is displayed. U:\>python -i "exit.py" Traceback (most recent call last): File "exit.py", line 2, in <module> sys.exit(0) SystemExit: 0 >>> Why is sys.exit() displaying a traceback

How to expect program exit in gtest?

假装没事ソ 提交于 2019-12-23 09:48:32
问题 I'm testing some code that uses CHECK from glog and I'd like to test that this check fails in certain scenarios. My code looks like: void MyClass::foo() { // stuff... // It's actually important that the binary gets aborted if this flag is false CHECK(some_flag) << "flag must be true"; // more stuff... } I've done some research into gtest and how I might be able to test for this. I found EXPECT_FATAL_FALIURE , EXPECT_NONFATAL_FAILURE , and HAS_FATAL_FAILURE but I haven't managed to figure out

Shutdown Hook c++

断了今生、忘了曾经 提交于 2019-12-23 09:16:16
问题 is there some way to run code on termination, no matter what kind termination (abnormal,normal,uncaught exception etc.)? I know its actually possible in Java, but is it even possible in C++? Im assuming a windows environment. 回答1: No -- if somebody invokes TerminateProcess , your process will be destroyed without further adieu, and (in particular) without any chance to run any more code in the process of shutting down. 回答2: For normal closing applciation I would suggest atexit() 回答3: One good

Exit from a console application in C#

狂风中的少年 提交于 2019-12-23 07:54:11
问题 I read a lot of things here on stackoverflow, comments, opinions and every kind of ideas. But anyway, I really need an explained way to exit my console application (I'm on VS2010 Framework 4) on C# with a custom error. The best thing I could read right now is on VB: Private Declare Sub ExitProcess Lib "kernel32" (ByVal uExitCode As Long) and use ExitProcess(1) for an error or ExitProcess(0) So my questions are: Is the same than Environment.Exit(1) ? What is the better for an application that

How to control when closing a window

ぐ巨炮叔叔 提交于 2019-12-23 05:32:13
问题 I have this code, which alerts the user that the window is about to be closed and the user may loose the data. If the user accpets the window closes, if not, the user stays on the page. <script language='javascript'> ClosingVar =true window.onbeforeunload = ExitCheck; function ExitCheck() { if(ClosingVar == true) { ExitCheck = false; return "YOU MAY LOOSE YOUR DATA."; } } </script> I want to be able to manage the option of the user. If the accept the closing option, then I want to call a