[Python-checkins] python/dist/src/Modules _tkinter.c,1.157,1.158
loewis@users.sourceforge.net
loewis@users.sourceforge.net
Fri, 09 May 2003 01:19:51 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv30645/Modules
Modified Files:
_tkinter.c
Log Message:
Patch #734118: Add {get|set}busywaitinterval.
Index: _tkinter.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_tkinter.c,v
retrieving revision 1.157
retrieving revision 1.158
diff -C2 -d -r1.157 -r1.158
*** _tkinter.c 3 May 2003 09:45:12 -0000 1.157
--- _tkinter.c 9 May 2003 08:19:48 -0000 1.158
***************
*** 319,322 ****
--- 319,324 ----
/**** Utils ****/
+ static int Tkinter_busywaitinterval = 20;
+
#ifdef WITH_THREAD
#ifndef MS_WINDOWS
***************
*** 2520,2524 ****
if(tcl_lock)PyThread_release_lock(tcl_lock);
if (result == 0)
! Sleep(20);
Py_END_ALLOW_THREADS
}
--- 2522,2526 ----
if(tcl_lock)PyThread_release_lock(tcl_lock);
if (result == 0)
! Sleep(Tkinter_busywaitinterval);
Py_END_ALLOW_THREADS
}
***************
*** 2832,2835 ****
--- 2834,2873 ----
}
+ 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[] =
{
***************
*** 2844,2847 ****
--- 2882,2889 ----
{"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}
};
***************
*** 2896,2900 ****
if(tcl_lock)PyThread_release_lock(tcl_lock);
if (result == 0)
! Sleep(20);
Py_END_ALLOW_THREADS
#else
--- 2938,2942 ----
if(tcl_lock)PyThread_release_lock(tcl_lock);
if (result == 0)
! Sleep(Tkinter_busywaitinterval);
Py_END_ALLOW_THREADS
#else