diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2003-05-09 08:19:48 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2003-05-09 08:19:48 (GMT) |
commit | 28e9ce9df20260ca39ce9583f499c53ba0a52370 (patch) | |
tree | bafc85dbc7343a5cb9fa7ec0e328d091570beabd | |
parent | 16e426bb15a7166c7463693036b82942d78043e1 (diff) | |
download | cpython-28e9ce9df20260ca39ce9583f499c53ba0a52370.zip cpython-28e9ce9df20260ca39ce9583f499c53ba0a52370.tar.gz cpython-28e9ce9df20260ca39ce9583f499c53ba0a52370.tar.bz2 |
Patch #734118: Add {get|set}busywaitinterval.
-rw-r--r-- | Misc/NEWS | 2 | ||||
-rw-r--r-- | Modules/_tkinter.c | 46 |
2 files changed, 46 insertions, 2 deletions
@@ -23,6 +23,8 @@ Core and builtins Extension modules ----------------- +- _tkinter.{get|set}busywaitinterval was added. + - itertools.islice() now accepts stop=None as documented. Fixes SF bug #730685. diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index a61bf7f..288ed15 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -318,6 +318,8 @@ Tkinter_Error(PyObject *v) /**** Utils ****/ +static int Tkinter_busywaitinterval = 20; + #ifdef WITH_THREAD #ifndef MS_WINDOWS @@ -2519,7 +2521,7 @@ Tkapp_MainLoop(PyObject *_self, PyObject *args) tcl_tstate = NULL; if(tcl_lock)PyThread_release_lock(tcl_lock); if (result == 0) - Sleep(20); + Sleep(Tkinter_busywaitinterval); Py_END_ALLOW_THREADS } #else @@ -2831,6 +2833,42 @@ Tkinter_Create(PyObject *self, PyObject *args) interactive, wantobjects); } +static PyObject * +Tkinter_setbusywaitinterval(PyObject *self, PyObject *args) +{ + int new_val; + if (!PyArg_ParseTuple(args, "i:setbusywaitinterval", &new_val)) + return NULL; + if (new_val < 0) { + PyErr_SetString(PyExc_ValueError, + "busywaitinterval must be >= 0"); + return NULL; + } + Tkinter_busywaitinterval = new_val; + Py_INCREF(Py_None); + return Py_None; +} + +static char setbusywaitinterval_doc[] = +"setbusywaitinterval(n) -> None\n\ +\n\ +Set the busy-wait interval in milliseconds between successive\n\ +calls to Tcl_DoOneEvent in a threaded Python interpreter.\n\ +It should be set to a divisor of the maximum time between\n\ +frames in an animation."; + +static PyObject * +Tkinter_getbusywaitinterval(PyObject *self, PyObject *args) +{ + return PyInt_FromLong(Tkinter_busywaitinterval); +} + +static char getbusywaitinterval_doc[] = +"getbusywaitinterval() -> int\n\ +\n\ +Return the current busy-wait interval between successive\n\ +calls to Tcl_DoOneEvent in a threaded Python interpreter."; + static PyMethodDef moduleMethods[] = { {"_flatten", Tkinter_Flatten, METH_VARARGS}, @@ -2843,6 +2881,10 @@ static PyMethodDef moduleMethods[] = {"mainloop", Tkapp_MainLoop, METH_VARARGS}, {"dooneevent", Tkapp_DoOneEvent, METH_VARARGS}, {"quit", Tkapp_Quit, METH_VARARGS}, + {"setbusywaitinterval",Tkinter_setbusywaitinterval, METH_VARARGS, + setbusywaitinterval_doc}, + {"getbusywaitinterval",(PyCFunction)Tkinter_getbusywaitinterval, + METH_NOARGS, getbusywaitinterval_doc}, {NULL, NULL} }; @@ -2895,7 +2937,7 @@ EventHook(void) tcl_tstate = NULL; if(tcl_lock)PyThread_release_lock(tcl_lock); if (result == 0) - Sleep(20); + Sleep(Tkinter_busywaitinterval); Py_END_ALLOW_THREADS #else result = Tcl_DoOneEvent(0); |