Kaydet (Commit) e42fc2fd authored tarafından Guido van Rossum's avatar Guido van Rossum

use getnewargs where it makes sense

üst 53bb7fff
...@@ -1005,12 +1005,8 @@ Tkapp_MainLoop (self, args) ...@@ -1005,12 +1005,8 @@ Tkapp_MainLoop (self, args)
{ {
int threshold = 0; int threshold = 0;
if (!PyArg_Parse (args, "")) if (!PyArg_ParseTuple (args, "|i", &threshold))
{
PyErr_Clear();
if (!PyArg_Parse (args, "i", &threshold))
return NULL; return NULL;
}
quitMainLoop = 0; quitMainLoop = 0;
while (tk_NumMainWindows > threshold && !quitMainLoop && !errorInCmd) while (tk_NumMainWindows > threshold && !quitMainLoop && !errorInCmd)
...@@ -1039,17 +1035,11 @@ Tkapp_DoOneEvent (self, args) ...@@ -1039,17 +1035,11 @@ Tkapp_DoOneEvent (self, args)
PyObject *self; PyObject *self;
PyObject *args; PyObject *args;
{ {
int flags; int flags = TK_ALL_EVENTS;
int rv; int rv;
if (PyArg_Parse (args, "")) if (!PyArg_ParseTuple (args, "|i", &flags))
flags = TK_ALL_EVENTS;
else
{
PyErr_Clear();
if (!PyArg_Parse (args, "i", &flags))
return NULL; return NULL;
}
rv = Tk_DoOneEvent(flags); rv = Tk_DoOneEvent(flags);
return Py_BuildValue ("i", rv); return Py_BuildValue ("i", rv);
} }
...@@ -1099,8 +1089,8 @@ static PyMethodDef Tkapp_methods[] = ...@@ -1099,8 +1089,8 @@ static PyMethodDef Tkapp_methods[] =
{"createfilehandler", Tkapp_CreateFileHandler}, {"createfilehandler", Tkapp_CreateFileHandler},
{"deletefilehandler", Tkapp_DeleteFileHandler}, {"deletefilehandler", Tkapp_DeleteFileHandler},
{"createtimerhandler", Tkapp_CreateTimerHandler}, {"createtimerhandler", Tkapp_CreateTimerHandler},
{"mainloop", Tkapp_MainLoop}, {"mainloop", Tkapp_MainLoop, 1},
{"dooneevent", Tkapp_DoOneEvent}, {"dooneevent", Tkapp_DoOneEvent, 1},
{"quit", Tkapp_Quit}, {"quit", Tkapp_Quit},
{NULL, NULL} {NULL, NULL}
}; };
...@@ -1151,8 +1141,8 @@ Tkinter_Create (self, args) ...@@ -1151,8 +1141,8 @@ Tkinter_Create (self, args)
PyObject *args; PyObject *args;
{ {
char *screenName = NULL; char *screenName = NULL;
char *baseName; char *baseName = NULL;
char *className; char *className = NULL;
int interactive = 0; int interactive = 0;
baseName = strrchr (getprogramname (), '/'); baseName = strrchr (getprogramname (), '/');
...@@ -1162,21 +1152,8 @@ Tkinter_Create (self, args) ...@@ -1162,21 +1152,8 @@ Tkinter_Create (self, args)
baseName = getprogramname (); baseName = getprogramname ();
className = "Tk"; className = "Tk";
if (PyArg_Parse (args, "")) if (!PyArg_ParseTuple (args, "|zssi",
/* VOID */ ;
else if (PyArg_Parse (args, "z",
&screenName))
/* VOID */ ;
else if (PyArg_Parse (args, "(zs)",
&screenName, &baseName))
/* VOID */ ;
else if (PyArg_Parse (args, "(zss)",
&screenName, &baseName, &className))
/* VOID */ ;
else if (PyArg_Parse (args, "(zssi)",
&screenName, &baseName, &className, &interactive)) &screenName, &baseName, &className, &interactive))
/* VOID */ ;
else
return NULL; return NULL;
return (PyObject *) Tkapp_New (screenName, baseName, className, return (PyObject *) Tkapp_New (screenName, baseName, className,
...@@ -1185,12 +1162,12 @@ Tkinter_Create (self, args) ...@@ -1185,12 +1162,12 @@ Tkinter_Create (self, args)
static PyMethodDef moduleMethods[] = static PyMethodDef moduleMethods[] =
{ {
{"create", Tkinter_Create}, {"create", Tkinter_Create, 1},
{"createfilehandler", Tkapp_CreateFileHandler}, {"createfilehandler", Tkapp_CreateFileHandler, 0},
{"deletefilehandler", Tkapp_DeleteFileHandler}, {"deletefilehandler", Tkapp_DeleteFileHandler, 0},
{"createtimerhandler", Tkapp_CreateTimerHandler}, {"createtimerhandler", Tkapp_CreateTimerHandler, 0},
{"mainloop", Tkapp_MainLoop}, {"mainloop", Tkapp_MainLoop, 1},
{"dooneevent", Tkapp_DoOneEvent}, {"dooneevent", Tkapp_DoOneEvent, 1},
{"quit", Tkapp_Quit}, {"quit", Tkapp_Quit},
{NULL, NULL} {NULL, NULL}
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment