Mercurial > cpython-lru_cache-weakref
annotate Modules/_tkinter.c @ 5792:dffabc620e4e legacy-trunk
Tweak re_tests and test_re to differentiate between
groups that have no value and groups that are out of bounds.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 15 Jul 1997 15:49:52 +0000 |
| parents | 02ea9d021427 |
| children | f1c03276873a |
| rev | line source |
|---|---|
| 3703 | 1 /*********************************************************** |
| 2 Copyright (C) 1994 Steen Lumholt. | |
| 3 Copyright 1994-1995 by Stichting Mathematisch Centrum, Amsterdam, | |
| 4 The Netherlands. | |
| 5 | |
| 6 All Rights Reserved | |
| 7 | |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4299
diff
changeset
|
8 Permission to use, copy, modify, and distribute this software and its |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4299
diff
changeset
|
9 documentation for any purpose and without fee is hereby granted, |
| 3703 | 10 provided that the above copyright notice appear in all copies and that |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4299
diff
changeset
|
11 both that copyright notice and this permission notice appear in |
| 3703 | 12 supporting documentation, and that the names of Stichting Mathematisch |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4299
diff
changeset
|
13 Centrum or CWI or Corporation for National Research Initiatives or |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4299
diff
changeset
|
14 CNRI not be used in advertising or publicity pertaining to |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4299
diff
changeset
|
15 distribution of the software without specific, written prior |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4299
diff
changeset
|
16 permission. |
| 3703 | 17 |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4299
diff
changeset
|
18 While CWI is the initial source for this software, a modified version |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4299
diff
changeset
|
19 is made available by the Corporation for National Research Initiatives |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4299
diff
changeset
|
20 (CNRI) at the Internet address ftp://ftp.python.org. |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4299
diff
changeset
|
21 |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4299
diff
changeset
|
22 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4299
diff
changeset
|
23 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4299
diff
changeset
|
24 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4299
diff
changeset
|
25 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4299
diff
changeset
|
26 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4299
diff
changeset
|
27 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4299
diff
changeset
|
28 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4299
diff
changeset
|
29 PERFORMANCE OF THIS SOFTWARE. |
| 3703 | 30 |
| 31 ******************************************************************/ | |
| 32 | |
| 33 /* _tkinter.c -- Interface to libtk.a and libtcl.a. */ | |
| 1664 | 34 |
|
4005
7495322427c7
Changes for Windows NT -- this time it works, with Tcl4.1p1 (p1!!!) etc.
Guido van Rossum <guido@python.org>
parents:
3973
diff
changeset
|
35 /* TCL/TK VERSION INFO: |
|
7495322427c7
Changes for Windows NT -- this time it works, with Tcl4.1p1 (p1!!!) etc.
Guido van Rossum <guido@python.org>
parents:
3973
diff
changeset
|
36 |
|
7495322427c7
Changes for Windows NT -- this time it works, with Tcl4.1p1 (p1!!!) etc.
Guido van Rossum <guido@python.org>
parents:
3973
diff
changeset
|
37 Unix: |
|
7495322427c7
Changes for Windows NT -- this time it works, with Tcl4.1p1 (p1!!!) etc.
Guido van Rossum <guido@python.org>
parents:
3973
diff
changeset
|
38 This should work with any version from Tcl 4.0 / Tck 7.4. |
|
7495322427c7
Changes for Windows NT -- this time it works, with Tcl4.1p1 (p1!!!) etc.
Guido van Rossum <guido@python.org>
parents:
3973
diff
changeset
|
39 Do not use older versions. |
|
7495322427c7
Changes for Windows NT -- this time it works, with Tcl4.1p1 (p1!!!) etc.
Guido van Rossum <guido@python.org>
parents:
3973
diff
changeset
|
40 |
|
7495322427c7
Changes for Windows NT -- this time it works, with Tcl4.1p1 (p1!!!) etc.
Guido van Rossum <guido@python.org>
parents:
3973
diff
changeset
|
41 Mac and Windows: |
|
7495322427c7
Changes for Windows NT -- this time it works, with Tcl4.1p1 (p1!!!) etc.
Guido van Rossum <guido@python.org>
parents:
3973
diff
changeset
|
42 Use Tcl 4.1p1 / Tk 7.5p1 or possibly newer. |
|
7495322427c7
Changes for Windows NT -- this time it works, with Tcl4.1p1 (p1!!!) etc.
Guido van Rossum <guido@python.org>
parents:
3973
diff
changeset
|
43 It does not seem to work reliably with the original 4.1/7.5 |
|
7495322427c7
Changes for Windows NT -- this time it works, with Tcl4.1p1 (p1!!!) etc.
Guido van Rossum <guido@python.org>
parents:
3973
diff
changeset
|
44 release. (4.0/7.4 were never released for these platforms.) |
|
7495322427c7
Changes for Windows NT -- this time it works, with Tcl4.1p1 (p1!!!) etc.
Guido van Rossum <guido@python.org>
parents:
3973
diff
changeset
|
45 */ |
|
7495322427c7
Changes for Windows NT -- this time it works, with Tcl4.1p1 (p1!!!) etc.
Guido van Rossum <guido@python.org>
parents:
3973
diff
changeset
|
46 |
| 3120 | 47 #include "Python.h" |
|
3973
3d1e4b76f745
Add optional casts to free() calls. (Jack)
Guido van Rossum <guido@python.org>
parents:
3899
diff
changeset
|
48 #include <ctype.h> |
| 3120 | 49 |
|
4079
a6e62c21b0e3
Add #define MAC_TCL for Mac.
Guido van Rossum <guido@python.org>
parents:
4005
diff
changeset
|
50 #ifdef macintosh |
|
a6e62c21b0e3
Add #define MAC_TCL for Mac.
Guido van Rossum <guido@python.org>
parents:
4005
diff
changeset
|
51 #define MAC_TCL |
|
5695
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
52 #include "myselect.h" |
|
4079
a6e62c21b0e3
Add #define MAC_TCL for Mac.
Guido van Rossum <guido@python.org>
parents:
4005
diff
changeset
|
53 #endif |
|
a6e62c21b0e3
Add #define MAC_TCL for Mac.
Guido van Rossum <guido@python.org>
parents:
4005
diff
changeset
|
54 |
| 1664 | 55 #include <tcl.h> |
| 56 #include <tk.h> | |
| 57 | |
|
3899
584936890f86
getprogramname --> Py_GetProgramName
Guido van Rossum <guido@python.org>
parents:
3703
diff
changeset
|
58 extern char *Py_GetProgramName (); |
| 1713 | 59 |
| 3120 | 60 /* Internal declarations from tkInt.h. */ |
| 61 #if (TK_MAJOR_VERSION*1000 + TK_MINOR_VERSION) >= 4001 | |
| 62 extern int Tk_GetNumMainWindows(); | |
| 63 #else | |
| 1664 | 64 extern int tk_NumMainWindows; |
| 3120 | 65 #define Tk_GetNumMainWindows() (tk_NumMainWindows) |
|
3413
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
66 #define NEED_TKCREATEMAINWINDOW 1 |
| 3120 | 67 #endif |
| 68 | |
| 69 #if TK_MAJOR_VERSION < 4 | |
| 1713 | 70 extern struct { Tk_Window win; } *tkMainWindowList; |
| 3120 | 71 #endif |
| 1664 | 72 |
|
3414
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
73 #ifdef macintosh |
|
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
74 |
|
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
75 /* |
|
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
76 ** Additional cruft needed by Tcl/Tk on the Mac. |
|
3973
3d1e4b76f745
Add optional casts to free() calls. (Jack)
Guido van Rossum <guido@python.org>
parents:
3899
diff
changeset
|
77 ** This is for Tcl 7.5 and Tk 4.1 (patch release 1). |
|
3414
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
78 */ |
|
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
79 |
|
4005
7495322427c7
Changes for Windows NT -- this time it works, with Tcl4.1p1 (p1!!!) etc.
Guido van Rossum <guido@python.org>
parents:
3973
diff
changeset
|
80 /* ckfree() expects a char* */ |
|
3973
3d1e4b76f745
Add optional casts to free() calls. (Jack)
Guido van Rossum <guido@python.org>
parents:
3899
diff
changeset
|
81 #define FREECAST (char *) |
|
3d1e4b76f745
Add optional casts to free() calls. (Jack)
Guido van Rossum <guido@python.org>
parents:
3899
diff
changeset
|
82 |
|
3414
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
83 #include <Events.h> /* For EventRecord */ |
|
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
84 |
|
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
85 typedef int (*TclMacConvertEventPtr) Py_PROTO((EventRecord *eventPtr)); |
|
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
86 void TclMacSetEventProc Py_PROTO((TclMacConvertEventPtr procPtr)); |
|
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
87 int TkMacConvertEvent Py_PROTO((EventRecord *eventPtr)); |
|
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
88 |
|
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
89 staticforward int PyMacConvertEvent Py_PROTO((EventRecord *eventPtr)); |
|
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
90 |
|
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
91 #endif /* macintosh */ |
|
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
92 |
|
3973
3d1e4b76f745
Add optional casts to free() calls. (Jack)
Guido van Rossum <guido@python.org>
parents:
3899
diff
changeset
|
93 #ifndef FREECAST |
|
4005
7495322427c7
Changes for Windows NT -- this time it works, with Tcl4.1p1 (p1!!!) etc.
Guido van Rossum <guido@python.org>
parents:
3973
diff
changeset
|
94 #define FREECAST (char *) |
|
3973
3d1e4b76f745
Add optional casts to free() calls. (Jack)
Guido van Rossum <guido@python.org>
parents:
3899
diff
changeset
|
95 #endif |
|
3d1e4b76f745
Add optional casts to free() calls. (Jack)
Guido van Rossum <guido@python.org>
parents:
3899
diff
changeset
|
96 |
| 1664 | 97 /**** Tkapp Object Declaration ****/ |
| 98 | |
| 99 staticforward PyTypeObject Tkapp_Type; | |
| 100 | |
| 101 typedef struct | |
| 4968 | 102 { |
| 103 PyObject_HEAD | |
| 104 Tcl_Interp *interp; | |
|
3413
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
105 #ifdef NEED_TKCREATEMAINWINDOW |
| 4968 | 106 Tk_Window tkwin; |
|
3413
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
107 #endif |
| 4968 | 108 } |
| 1664 | 109 TkappObject; |
| 110 | |
| 111 #define Tkapp_Check(v) ((v)->ob_type == &Tkapp_Type) | |
|
3413
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
112 #ifdef NEED_TKCREATEMAINWINDOW |
| 1664 | 113 #define Tkapp_Tkwin(v) (((TkappObject *) (v))->tkwin) |
|
3413
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
114 #endif |
| 1664 | 115 #define Tkapp_Interp(v) (((TkappObject *) (v))->interp) |
| 116 #define Tkapp_Result(v) (((TkappObject *) (v))->interp->result) | |
| 117 | |
| 118 #define DEBUG_REFCNT(v) (printf ("DEBUG: id=%p, refcnt=%i\n", \ | |
| 4968 | 119 (void *) v, ((PyObject *) v)->ob_refcnt)) |
| 1664 | 120 |
| 4968 | 121 |
| 122 | |
| 1664 | 123 /**** Error Handling ****/ |
| 124 | |
| 125 static PyObject *Tkinter_TclError; | |
| 1713 | 126 static int quitMainLoop = 0; |
| 1664 | 127 static int errorInCmd = 0; |
| 128 static PyObject *excInCmd; | |
| 129 static PyObject *valInCmd; | |
|
2055
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
2009
diff
changeset
|
130 static PyObject *trbInCmd; |
| 1664 | 131 |
| 4968 | 132 |
| 133 | |
| 1664 | 134 static PyObject * |
| 4968 | 135 Tkinter_Error(v) |
| 136 PyObject *v; | |
| 1664 | 137 { |
| 4968 | 138 PyErr_SetString(Tkinter_TclError, Tkapp_Result(v)); |
| 139 return NULL; | |
| 1664 | 140 } |
| 141 | |
| 4968 | 142 |
| 1664 | 143 int |
| 4968 | 144 PythonCmd_Error(interp) |
| 145 Tcl_Interp *interp; | |
| 1664 | 146 { |
| 4968 | 147 errorInCmd = 1; |
| 148 PyErr_Fetch(&excInCmd, &valInCmd, &trbInCmd); | |
| 149 return TCL_ERROR; | |
| 1664 | 150 } |
| 151 | |
| 4968 | 152 |
| 153 | |
| 1664 | 154 /**** Utils ****/ |
| 155 static char * | |
| 4968 | 156 AsString(value, tmp) |
| 157 PyObject *value; | |
| 158 PyObject *tmp; | |
| 1664 | 159 { |
| 4968 | 160 if (PyString_Check (value)) |
| 161 return PyString_AsString (value); | |
| 162 else { | |
| 163 PyObject *v = PyObject_Str(value); | |
| 164 PyList_Append(tmp, v); | |
| 165 Py_DECREF(v); | |
| 166 return PyString_AsString(v); | |
| 167 } | |
| 1664 | 168 } |
| 169 | |
| 4968 | 170 |
| 171 | |
| 1664 | 172 #define ARGSZ 64 |
| 173 | |
| 174 static char * | |
| 4968 | 175 Merge(args) |
| 176 PyObject *args; | |
| 1664 | 177 { |
| 4968 | 178 PyObject *tmp = NULL; |
| 179 char *argvStore[ARGSZ]; | |
| 180 char **argv = NULL; | |
| 181 int fvStore[ARGSZ]; | |
| 182 int *fv = NULL; | |
| 183 int argc = 0, i; | |
| 184 char *res = NULL; | |
| 185 | |
| 186 if (!(tmp = PyList_New(0))) | |
| 187 return NULL; | |
| 188 | |
| 189 argv = argvStore; | |
| 190 fv = fvStore; | |
| 191 | |
| 192 if (args == NULL) | |
| 193 argc = 0; | |
| 1664 | 194 |
| 4968 | 195 else if (!PyTuple_Check(args)) { |
| 196 argc = 1; | |
| 197 fv[0] = 0; | |
| 198 argv[0] = AsString(args, tmp); | |
| 199 } | |
| 200 else { | |
| 201 argc = PyTuple_Size(args); | |
| 202 | |
| 203 if (argc > ARGSZ) { | |
| 204 argv = (char **)ckalloc(argc * sizeof (char *)); | |
| 205 fv = (int *)ckalloc(argc * sizeof (int)); | |
| 206 if (argv == NULL || fv == NULL) { | |
| 207 PyErr_NoMemory(); | |
| 208 goto finally; | |
| 209 } | |
| 210 } | |
| 1664 | 211 |
| 4968 | 212 for (i = 0; i < argc; i++) { |
| 213 PyObject *v = PyTuple_GetItem(args, i); | |
| 214 if (PyTuple_Check(v)) { | |
| 215 fv[i] = 1; | |
| 216 if (!(argv[i] = Merge(v))) | |
| 217 goto finally; | |
| 218 } | |
| 219 else if (v == Py_None) { | |
| 220 argc = i; | |
| 221 break; | |
| 222 } | |
| 223 else { | |
| 224 fv[i] = 0; | |
| 225 argv[i] = AsString(v, tmp); | |
| 226 } | |
| 227 } | |
| 228 } | |
| 229 res = Tcl_Merge(argc, argv); | |
| 1664 | 230 |
| 4968 | 231 finally: |
| 232 for (i = 0; i < argc; i++) | |
| 233 if (fv[i]) { | |
| 234 ckfree(argv[i]); | |
| 235 } | |
| 236 if (argv != argvStore) | |
| 237 ckfree(FREECAST argv); | |
| 238 if (fv != fvStore) | |
| 239 ckfree(FREECAST fv); | |
| 240 | |
| 241 Py_DECREF(tmp); | |
| 242 return res; | |
| 243 } | |
| 244 | |
| 245 | |
| 246 | |
| 247 static PyObject * | |
| 248 Split(self, list) | |
| 249 PyObject *self; | |
| 250 char *list; | |
| 251 { | |
| 252 int argc; | |
| 253 char **argv; | |
| 254 PyObject *v; | |
| 255 | |
| 256 if (list == NULL) { | |
| 257 Py_INCREF(Py_None); | |
| 258 return Py_None; | |
| 1664 | 259 } |
| 260 | |
| 4968 | 261 if (Tcl_SplitList(Tkapp_Interp(self), list, &argc, &argv) == TCL_ERROR) |
| 1664 | 262 { |
| 4968 | 263 /* Not a list. |
| 264 * Could be a quoted string containing funnies, e.g. {"}. | |
| 265 * Return the string itself. | |
| 266 */ | |
| 267 PyErr_Clear(); | |
| 268 return PyString_FromString(list); | |
| 1664 | 269 } |
| 270 | |
| 4968 | 271 if (argc == 0) |
| 272 v = PyString_FromString(""); | |
| 273 else if (argc == 1) | |
| 274 v = PyString_FromString(argv[0]); | |
| 275 else if ((v = PyTuple_New (argc)) != NULL) { | |
| 276 int i; | |
| 277 PyObject *w; | |
| 1664 | 278 |
| 4968 | 279 for (i = 0; i < argc; i++) { |
| 280 if ((w = Split(self, argv[i])) == NULL) { | |
| 281 Py_DECREF(v); | |
| 282 v = NULL; | |
| 283 break; | |
| 284 } | |
| 285 PyTuple_SetItem(v, i, w); | |
| 286 } | |
| 287 } | |
| 288 ckfree (FREECAST argv); | |
| 289 return v; | |
| 1664 | 290 } |
| 291 | |
| 292 | |
| 4968 | 293 |
| 1664 | 294 /**** Tkapp Object ****/ |
| 295 | |
| 296 #ifndef WITH_APPINIT | |
| 297 int | |
| 298 Tcl_AppInit (interp) | |
| 4968 | 299 Tcl_Interp *interp; |
| 1664 | 300 { |
| 4968 | 301 Tk_Window main; |
|
3414
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
302 |
| 4968 | 303 main = Tk_MainWindow(interp); |
| 304 if (Tcl_Init(interp) == TCL_ERROR) { | |
| 305 fprintf(stderr, "Tcl_Init error: %s\n", interp->result); | |
| 306 return TCL_ERROR; | |
| 307 } | |
| 308 if (Tk_Init(interp) == TCL_ERROR) { | |
| 309 fprintf(stderr, "Tk_Init error: %s\n", interp->result); | |
| 310 return TCL_ERROR; | |
| 311 } | |
| 312 return TCL_OK; | |
| 1664 | 313 } |
| 4968 | 314 #endif /* !WITH_APPINIT */ |
|
3413
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
315 |
| 4968 | 316 |
| 317 | |
| 1664 | 318 |
| 319 /* Initialize the Tk application; see the `main' function in | |
| 4968 | 320 * `tkMain.c'. |
| 321 */ | |
| 1664 | 322 static TkappObject * |
| 4968 | 323 Tkapp_New(screenName, baseName, className, interactive) |
| 324 char *screenName; | |
| 325 char *baseName; | |
| 326 char *className; | |
| 327 int interactive; | |
| 1664 | 328 { |
| 4968 | 329 TkappObject *v; |
| 330 char *argv0; | |
| 1664 | 331 |
| 4968 | 332 v = PyObject_NEW(TkappObject, &Tkapp_Type); |
| 333 if (v == NULL) | |
| 334 return NULL; | |
| 1664 | 335 |
| 4968 | 336 v->interp = Tcl_CreateInterp(); |
|
3413
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
337 |
|
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
338 #ifdef NEED_TKCREATEMAINWINDOW |
| 4968 | 339 v->tkwin = Tk_CreateMainWindow(v->interp, screenName, |
| 340 baseName, className); | |
| 341 if (v->tkwin == NULL) | |
| 342 return (TkappObject *)Tkinter_Error((PyObject *) v); | |
| 1664 | 343 |
| 4968 | 344 Tk_GeometryRequest(v->tkwin, 200, 200); |
|
3413
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
345 #endif |
| 1664 | 346 |
| 4968 | 347 if (screenName != NULL) |
| 348 Tcl_SetVar2(v->interp, "env", "DISPLAY", | |
| 349 screenName, TCL_GLOBAL_ONLY); | |
| 1664 | 350 |
| 4968 | 351 if (interactive) |
| 352 Tcl_SetVar(v->interp, "tcl_interactive", "1", TCL_GLOBAL_ONLY); | |
| 353 else | |
| 354 Tcl_SetVar(v->interp, "tcl_interactive", "0", TCL_GLOBAL_ONLY); | |
| 1664 | 355 |
| 4968 | 356 /* This is used to get the application class for Tk 4.1 and up */ |
| 357 argv0 = (char*)ckalloc(strlen(className) + 1); | |
| 358 if (!argv0) { | |
| 359 PyErr_NoMemory(); | |
| 360 Py_DECREF(v); | |
| 361 return NULL; | |
| 362 } | |
|
3973
3d1e4b76f745
Add optional casts to free() calls. (Jack)
Guido van Rossum <guido@python.org>
parents:
3899
diff
changeset
|
363 |
| 4968 | 364 strcpy(argv0, className); |
| 365 if (isupper(argv0[0])) | |
| 366 argv0[0] = tolower(argv0[0]); | |
| 367 Tcl_SetVar(v->interp, "argv0", argv0, TCL_GLOBAL_ONLY); | |
| 368 ckfree(argv0); | |
| 1664 | 369 |
| 4968 | 370 if (Tcl_AppInit(v->interp) != TCL_OK) |
| 371 return (TkappObject *)Tkinter_Error(v); | |
| 372 | |
| 373 return v; | |
| 1664 | 374 } |
| 375 | |
| 4968 | 376 |
| 377 | |
| 1664 | 378 /** Tcl Eval **/ |
| 379 | |
| 380 static PyObject * | |
| 4968 | 381 Tkapp_Call(self, args) |
| 382 PyObject *self; | |
| 383 PyObject *args; | |
| 1664 | 384 { |
| 4968 | 385 char *cmd = Merge(args); |
| 386 PyObject *res = NULL; | |
| 387 | |
| 388 if (!cmd) | |
| 389 PyErr_SetString(Tkinter_TclError, "merge failed"); | |
| 390 | |
| 391 else if (Tcl_Eval(Tkapp_Interp(self), cmd) == TCL_ERROR) | |
| 392 res = Tkinter_Error(self); | |
| 393 | |
| 394 else | |
| 395 res = PyString_FromString(Tkapp_Result(self)); | |
| 396 | |
| 397 if (cmd) | |
| 398 ckfree(cmd); | |
| 399 | |
| 400 return res; | |
| 401 } | |
| 1664 | 402 |
| 4968 | 403 |
| 404 static PyObject * | |
| 405 Tkapp_GlobalCall(self, args) | |
| 406 PyObject *self; | |
| 407 PyObject *args; | |
| 408 { | |
| 409 char *cmd = Merge(args); | |
| 410 PyObject *res = NULL; | |
| 411 | |
| 1664 | 412 |
| 4968 | 413 if (!cmd) |
| 414 PyErr_SetString(Tkinter_TclError, "merge failed"); | |
| 415 | |
| 416 else if (Tcl_GlobalEval(Tkapp_Interp(self), cmd) == TCL_ERROR) | |
| 417 res = Tkinter_Error(self); | |
| 418 else | |
| 419 res = PyString_FromString(Tkapp_Result(self)); | |
| 420 | |
| 421 if (cmd) | |
| 422 ckfree(cmd); | |
| 423 | |
| 424 return res; | |
| 1664 | 425 } |
| 426 | |
| 427 static PyObject * | |
| 4968 | 428 Tkapp_Eval(self, args) |
| 429 PyObject *self; | |
| 430 PyObject *args; | |
| 1664 | 431 { |
| 4968 | 432 char *script; |
| 433 | |
| 434 if (!PyArg_Parse (args, "s", &script)) | |
| 435 return NULL; | |
| 1664 | 436 |
| 4968 | 437 if (Tcl_Eval(Tkapp_Interp(self), script) == TCL_ERROR) |
| 438 return Tkinter_Error(self); | |
| 1664 | 439 |
| 4968 | 440 return PyString_FromString(Tkapp_Result(self)); |
| 1664 | 441 } |
| 442 | |
| 443 static PyObject * | |
| 4968 | 444 Tkapp_GlobalEval(self, args) |
| 445 PyObject *self; | |
| 446 PyObject *args; | |
| 1664 | 447 { |
| 4968 | 448 char *script; |
| 1664 | 449 |
| 4968 | 450 if (!PyArg_Parse(args, "s", &script)) |
| 451 return NULL; | |
| 1664 | 452 |
| 4968 | 453 if (Tcl_GlobalEval(Tkapp_Interp(self), script) == TCL_ERROR) |
| 454 return Tkinter_Error (self); | |
| 1664 | 455 |
| 4968 | 456 return PyString_FromString(Tkapp_Result(self)); |
| 1664 | 457 } |
| 458 | |
| 459 static PyObject * | |
| 460 Tkapp_EvalFile (self, args) | |
| 4968 | 461 PyObject *self; |
| 462 PyObject *args; | |
| 1664 | 463 { |
| 4968 | 464 char *fileName; |
| 1664 | 465 |
| 4968 | 466 if (!PyArg_Parse(args, "s", &fileName)) |
| 467 return NULL; | |
| 1664 | 468 |
| 4968 | 469 if (Tcl_EvalFile(Tkapp_Interp(self), fileName) == TCL_ERROR) |
| 470 return Tkinter_Error (self); | |
| 1664 | 471 |
| 4968 | 472 return PyString_FromString(Tkapp_Result(self)); |
| 1664 | 473 } |
| 474 | |
| 475 static PyObject * | |
| 4968 | 476 Tkapp_Record(self, args) |
| 477 PyObject *self; | |
| 478 PyObject *args; | |
| 1664 | 479 { |
| 4968 | 480 char *script; |
| 1664 | 481 |
| 4968 | 482 if (!PyArg_Parse(args, "s", &script)) |
| 483 return NULL; | |
| 1664 | 484 |
| 4968 | 485 if (TCL_ERROR == Tcl_RecordAndEval(Tkapp_Interp(self), |
| 486 script, TCL_NO_EVAL)) | |
| 487 return Tkinter_Error (self); | |
| 1664 | 488 |
| 4968 | 489 return PyString_FromString(Tkapp_Result(self)); |
| 1664 | 490 } |
| 491 | |
| 492 static PyObject * | |
| 4968 | 493 Tkapp_AddErrorInfo(self, args) |
| 494 PyObject *self; | |
| 495 PyObject *args; | |
| 1664 | 496 { |
| 4968 | 497 char *msg; |
| 1664 | 498 |
| 4968 | 499 if (!PyArg_Parse (args, "s", &msg)) |
| 500 return NULL; | |
| 501 Tcl_AddErrorInfo(Tkapp_Interp(self), msg); | |
| 1664 | 502 |
| 4968 | 503 Py_INCREF(Py_None); |
| 504 return Py_None; | |
| 1664 | 505 } |
| 506 | |
| 4968 | 507 |
| 508 | |
| 1664 | 509 /** Tcl Variable **/ |
| 510 | |
| 511 static PyObject * | |
| 4968 | 512 SetVar(self, args, flags) |
| 513 PyObject *self; | |
| 514 PyObject *args; | |
| 515 int flags; | |
| 1664 | 516 { |
| 4968 | 517 char *name1, *name2, *ok; |
| 518 PyObject *newValue; | |
| 519 PyObject *tmp = PyList_New(0); | |
| 1664 | 520 |
| 4968 | 521 if (!tmp) |
| 522 return NULL; | |
| 1664 | 523 |
| 4968 | 524 if (PyArg_Parse(args, "(sO)", &name1, &newValue)) |
| 525 /* XXX Merge? */ | |
| 526 ok = Tcl_SetVar(Tkapp_Interp (self), name1, | |
| 527 AsString (newValue, tmp), flags); | |
| 1664 | 528 |
| 4968 | 529 else if (PyArg_Parse(args, "(ssO)", &name1, &name2, &newValue)) |
| 530 ok = Tcl_SetVar2(Tkapp_Interp (self), name1, name2, | |
| 531 AsString (newValue, tmp), flags); | |
| 532 else { | |
| 533 Py_DECREF (tmp); | |
| 534 return NULL; | |
| 535 } | |
| 536 Py_DECREF (tmp); | |
| 1664 | 537 |
| 4968 | 538 if (!ok) |
| 539 return Tkinter_Error(self); | |
| 540 | |
| 541 Py_INCREF(Py_None); | |
| 542 return Py_None; | |
| 1664 | 543 } |
| 544 | |
| 545 static PyObject * | |
| 546 Tkapp_SetVar (self, args) | |
| 4968 | 547 PyObject *self; |
| 548 PyObject *args; | |
| 1664 | 549 { |
| 4968 | 550 return SetVar(self, args, TCL_LEAVE_ERR_MSG); |
| 1664 | 551 } |
| 552 | |
| 553 static PyObject * | |
| 554 Tkapp_GlobalSetVar (self, args) | |
| 4968 | 555 PyObject *self; |
| 556 PyObject *args; | |
| 1664 | 557 { |
| 4968 | 558 return SetVar(self, args, TCL_LEAVE_ERR_MSG | TCL_GLOBAL_ONLY); |
| 1664 | 559 } |
| 560 | |
| 4968 | 561 |
| 562 | |
| 1664 | 563 static PyObject * |
| 564 GetVar (self, args, flags) | |
| 4968 | 565 PyObject *self; |
| 566 PyObject *args; | |
| 567 int flags; | |
| 1664 | 568 { |
| 4968 | 569 char *name1, *name2, *s; |
| 570 | |
| 571 if (PyArg_Parse(args, "s", &name1)) | |
| 572 s = Tcl_GetVar(Tkapp_Interp (self), name1, flags); | |
| 1664 | 573 |
| 4968 | 574 else if (PyArg_Parse(args, "(ss)", &name1, &name2)) |
| 575 s = Tcl_GetVar2(Tkapp_Interp(self), name1, name2, flags); | |
| 576 else | |
| 577 return NULL; | |
| 1664 | 578 |
| 4968 | 579 if (s == NULL) |
| 580 return Tkinter_Error(self); | |
| 1664 | 581 |
| 4968 | 582 return PyString_FromString (s); |
| 1664 | 583 } |
| 584 | |
| 585 static PyObject * | |
| 586 Tkapp_GetVar (self, args) | |
| 4968 | 587 PyObject *self; |
| 588 PyObject *args; | |
| 1664 | 589 { |
| 4968 | 590 return GetVar(self, args, TCL_LEAVE_ERR_MSG); |
| 1664 | 591 } |
| 592 | |
| 593 static PyObject * | |
| 594 Tkapp_GlobalGetVar (self, args) | |
| 4968 | 595 PyObject *self; |
| 596 PyObject *args; | |
| 1664 | 597 { |
| 4968 | 598 return GetVar(self, args, TCL_LEAVE_ERR_MSG | TCL_GLOBAL_ONLY); |
| 1664 | 599 } |
| 600 | |
| 4968 | 601 |
| 602 | |
| 1664 | 603 static PyObject * |
| 604 UnsetVar (self, args, flags) | |
| 4968 | 605 PyObject *self; |
| 606 PyObject *args; | |
| 607 int flags; | |
| 1664 | 608 { |
| 4968 | 609 char *name1, *name2; |
| 610 int code; | |
| 611 | |
| 612 if (PyArg_Parse(args, "s", &name1)) | |
| 613 code = Tcl_UnsetVar(Tkapp_Interp (self), name1, flags); | |
| 1664 | 614 |
| 4968 | 615 else if (PyArg_Parse(args, "(ss)", &name1, &name2)) |
| 616 code = Tcl_UnsetVar2(Tkapp_Interp(self), name1, name2, flags); | |
| 617 else | |
| 618 return NULL; | |
| 1664 | 619 |
| 4968 | 620 if (code == TCL_ERROR) |
| 621 return Tkinter_Error (self); | |
| 1664 | 622 |
| 4968 | 623 Py_INCREF(Py_None); |
| 624 return Py_None; | |
| 1664 | 625 } |
| 626 | |
| 627 static PyObject * | |
| 628 Tkapp_UnsetVar (self, args) | |
| 4968 | 629 PyObject *self; |
| 630 PyObject *args; | |
| 1664 | 631 { |
| 4968 | 632 return UnsetVar(self, args, TCL_LEAVE_ERR_MSG); |
| 1664 | 633 } |
| 634 | |
| 635 static PyObject * | |
| 636 Tkapp_GlobalUnsetVar (self, args) | |
| 4968 | 637 PyObject *self; |
| 638 PyObject *args; | |
| 1664 | 639 { |
| 4968 | 640 return UnsetVar(self, args, TCL_LEAVE_ERR_MSG | TCL_GLOBAL_ONLY); |
| 1664 | 641 } |
| 642 | |
| 4968 | 643 |
| 644 | |
| 1664 | 645 /** Tcl to Python **/ |
| 646 | |
| 647 static PyObject * | |
| 648 Tkapp_GetInt (self, args) | |
| 4968 | 649 PyObject *self; |
| 650 PyObject *args; | |
| 1664 | 651 { |
| 4968 | 652 char *s; |
| 653 int v; | |
| 1664 | 654 |
| 4968 | 655 if (!PyArg_Parse(args, "s", &s)) |
| 656 return NULL; | |
| 657 if (Tcl_GetInt(Tkapp_Interp (self), s, &v) == TCL_ERROR) | |
| 658 return Tkinter_Error(self); | |
| 659 return Py_BuildValue("i", v); | |
| 1664 | 660 } |
| 661 | |
| 662 static PyObject * | |
| 663 Tkapp_GetDouble (self, args) | |
| 4968 | 664 PyObject *self; |
| 665 PyObject *args; | |
| 1664 | 666 { |
| 4968 | 667 char *s; |
| 668 double v; | |
| 1664 | 669 |
| 4968 | 670 if (!PyArg_Parse(args, "s", &s)) |
| 671 return NULL; | |
| 672 if (Tcl_GetDouble(Tkapp_Interp (self), s, &v) == TCL_ERROR) | |
| 673 return Tkinter_Error(self); | |
| 674 return Py_BuildValue("d", v); | |
| 1664 | 675 } |
| 676 | |
| 677 static PyObject * | |
| 678 Tkapp_GetBoolean (self, args) | |
| 4968 | 679 PyObject *self; |
| 680 PyObject *args; | |
| 1664 | 681 { |
| 4968 | 682 char *s; |
| 683 int v; | |
| 1664 | 684 |
| 4968 | 685 if (!PyArg_Parse(args, "s", &s)) |
| 686 return NULL; | |
| 687 if (Tcl_GetBoolean(Tkapp_Interp (self), s, &v) == TCL_ERROR) | |
| 688 return Tkinter_Error (self); | |
| 689 return Py_BuildValue("i", v); | |
| 1664 | 690 } |
| 691 | |
| 692 static PyObject * | |
| 693 Tkapp_ExprString (self, args) | |
| 4968 | 694 PyObject *self; |
| 695 PyObject *args; | |
| 1664 | 696 { |
| 4968 | 697 char *s; |
| 1664 | 698 |
| 4968 | 699 if (!PyArg_Parse(args, "s", &s)) |
| 700 return NULL; | |
| 701 if (Tcl_ExprString (Tkapp_Interp (self), s) == TCL_ERROR) | |
| 702 return Tkinter_Error(self); | |
| 703 return Py_BuildValue("s", Tkapp_Result(self)); | |
| 1664 | 704 } |
| 705 | |
| 706 static PyObject * | |
| 707 Tkapp_ExprLong (self, args) | |
| 4968 | 708 PyObject *self; |
| 709 PyObject *args; | |
| 1664 | 710 { |
| 4968 | 711 char *s; |
| 712 long v; | |
| 1664 | 713 |
| 4968 | 714 if (!PyArg_Parse(args, "s", &s)) |
| 715 return NULL; | |
| 716 if (Tcl_ExprLong(Tkapp_Interp(self), s, &v) == TCL_ERROR) | |
| 717 return Tkinter_Error(self); | |
| 718 return Py_BuildValue("l", v); | |
| 1664 | 719 } |
| 720 | |
| 721 static PyObject * | |
| 722 Tkapp_ExprDouble (self, args) | |
| 4968 | 723 PyObject *self; |
| 724 PyObject *args; | |
| 1664 | 725 { |
| 4968 | 726 char *s; |
| 727 double v; | |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
4968
diff
changeset
|
728 int retval; |
| 1664 | 729 |
| 4968 | 730 if (!PyArg_Parse(args, "s", &s)) |
| 731 return NULL; | |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
4968
diff
changeset
|
732 PyFPE_START_PROTECT("Tkapp_ExprDouble", return 0) |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
4968
diff
changeset
|
733 retval = Tcl_ExprDouble (Tkapp_Interp (self), s, &v); |
|
5197
74c12704a0bd
New form of PyFPE_END_PROTECT macro.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
734 PyFPE_END_PROTECT(retval) |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
4968
diff
changeset
|
735 if (retval == TCL_ERROR) |
| 4968 | 736 return Tkinter_Error(self); |
| 737 return Py_BuildValue("d", v); | |
| 1664 | 738 } |
| 739 | |
| 740 static PyObject * | |
| 741 Tkapp_ExprBoolean (self, args) | |
| 4968 | 742 PyObject *self; |
| 743 PyObject *args; | |
| 1664 | 744 { |
| 4968 | 745 char *s; |
| 746 int v; | |
| 1664 | 747 |
| 4968 | 748 if (!PyArg_Parse(args, "s", &s)) |
| 749 return NULL; | |
| 750 if (Tcl_ExprBoolean(Tkapp_Interp(self), s, &v) == TCL_ERROR) | |
| 751 return Tkinter_Error(self); | |
| 752 return Py_BuildValue("i", v); | |
| 1664 | 753 } |
| 754 | |
| 4968 | 755 |
| 756 | |
| 1664 | 757 static PyObject * |
| 758 Tkapp_SplitList (self, args) | |
| 4968 | 759 PyObject *self; |
| 760 PyObject *args; | |
| 1664 | 761 { |
| 4968 | 762 char *list; |
| 763 int argc; | |
| 764 char **argv; | |
| 765 PyObject *v; | |
| 766 int i; | |
| 767 | |
| 768 if (!PyArg_Parse(args, "s", &list)) | |
| 769 return NULL; | |
| 770 | |
| 771 if (Tcl_SplitList(Tkapp_Interp(self), list, &argc, &argv) == TCL_ERROR) | |
| 772 return Tkinter_Error(self); | |
| 1664 | 773 |
| 4968 | 774 if (!(v = PyTuple_New(argc))) |
| 775 return NULL; | |
| 776 | |
| 777 for (i = 0; i < argc; i++) { | |
| 778 PyObject *s = PyString_FromString(argv[i]); | |
| 779 if (!s || PyTuple_SetItem(v, i, s)) { | |
| 780 Py_DECREF(v); | |
| 781 v = NULL; | |
| 782 goto finally; | |
| 783 } | |
| 784 } | |
| 1664 | 785 |
| 4968 | 786 finally: |
| 787 ckfree(FREECAST argv); | |
| 788 return v; | |
| 1664 | 789 } |
| 790 | |
| 791 static PyObject * | |
| 792 Tkapp_Split (self, args) | |
| 4968 | 793 PyObject *self; |
| 794 PyObject *args; | |
| 1664 | 795 { |
| 4968 | 796 char *list; |
| 1664 | 797 |
| 4968 | 798 if (!PyArg_Parse(args, "s", &list)) |
| 799 return NULL; | |
| 800 return Split(self, list); | |
| 1664 | 801 } |
| 802 | |
| 803 static PyObject * | |
| 804 Tkapp_Merge (self, args) | |
| 4968 | 805 PyObject *self; |
| 806 PyObject *args; | |
| 1664 | 807 { |
| 4968 | 808 char *s = Merge(args); |
| 809 PyObject *res = NULL; | |
| 1664 | 810 |
| 4968 | 811 if (s) { |
| 812 res = PyString_FromString(s); | |
| 813 ckfree(s); | |
| 814 } | |
| 815 else | |
| 816 PyErr_SetString(Tkinter_TclError, "merge failed"); | |
| 817 | |
| 818 return res; | |
| 1664 | 819 } |
| 820 | |
| 4968 | 821 |
| 822 | |
| 1664 | 823 /** Tcl Command **/ |
| 824 | |
| 825 /* This is the Tcl command that acts as a wrapper for Python | |
| 4968 | 826 * function or method. |
| 827 */ | |
| 1664 | 828 static int |
| 829 PythonCmd (clientData, interp, argc, argv) | |
| 4968 | 830 ClientData clientData; /* Is (self, func) */ |
| 831 Tcl_Interp *interp; | |
| 832 int argc; | |
| 833 char *argv[]; | |
| 1664 | 834 { |
| 4968 | 835 PyObject *self, *func, *arg, *res, *tmp; |
| 836 int i; | |
| 1664 | 837 |
| 4968 | 838 /* TBD: no error checking here since we know, via the |
| 839 * Tkapp_CreateCommand() that the client data is a two-tuple | |
| 840 */ | |
| 841 self = PyTuple_GetItem((PyObject *) clientData, 0); | |
| 842 func = PyTuple_GetItem((PyObject *) clientData, 1); | |
| 843 | |
| 844 /* Create argument list (argv1, ..., argvN) */ | |
| 845 if (!(arg = PyTuple_New(argc - 1))) | |
| 846 return PythonCmd_Error(interp); | |
| 1664 | 847 |
| 4968 | 848 for (i = 0; i < (argc - 1); i++) { |
| 849 PyObject *s = PyString_FromString(argv[i + 1]); | |
| 850 if (!s || PyTuple_SetItem(arg, i, s)) { | |
| 851 Py_DECREF(arg); | |
| 852 PythonCmd_Error(interp); | |
| 853 } | |
| 854 } | |
| 855 res = PyEval_CallObject(func, arg); | |
| 856 Py_DECREF(arg); | |
| 1713 | 857 |
| 4968 | 858 if (res == NULL) |
| 859 return PythonCmd_Error(interp); | |
| 1664 | 860 |
| 4968 | 861 if (!(tmp = PyList_New(0))) { |
| 862 Py_DECREF(res); | |
| 863 return PythonCmd_Error(interp); | |
| 864 } | |
| 1664 | 865 |
| 4968 | 866 Tcl_SetResult(Tkapp_Interp(self), AsString(res, tmp), TCL_VOLATILE); |
| 867 Py_DECREF(res); | |
| 868 Py_DECREF(tmp); | |
| 869 | |
| 870 return TCL_OK; | |
| 1664 | 871 } |
| 872 | |
| 873 static void | |
| 874 PythonCmdDelete (clientData) | |
| 4968 | 875 ClientData clientData; /* Is (self, func) */ |
| 1664 | 876 { |
| 4968 | 877 Py_DECREF((PyObject *) clientData); |
| 1664 | 878 } |
| 879 | |
| 4968 | 880 |
| 881 | |
| 1664 | 882 static PyObject * |
| 883 Tkapp_CreateCommand (self, args) | |
| 4968 | 884 PyObject *self; |
| 885 PyObject *args; | |
| 1664 | 886 { |
| 4968 | 887 char *cmdName; |
| 888 PyObject *data; | |
| 889 PyObject *func; | |
| 1664 | 890 |
| 4968 | 891 /* Args is: (cmdName, func) */ |
| 892 if (!PyTuple_Check(args) | |
| 893 || !(PyTuple_Size(args) == 2) | |
| 894 || !PyString_Check(PyTuple_GetItem(args, 0)) | |
| 895 || !PyCallable_Check(PyTuple_GetItem(args, 1))) | |
| 896 { | |
| 897 PyErr_SetString (PyExc_TypeError, "bad argument list"); | |
| 898 return NULL; | |
| 899 } | |
| 1664 | 900 |
| 4968 | 901 cmdName = PyString_AsString(PyTuple_GetItem(args, 0)); |
| 902 func = PyTuple_GetItem(args, 1); | |
| 1664 | 903 |
| 4968 | 904 data = PyTuple_New(2); /* ClientData is: (self, func) */ |
| 905 if (!data) | |
| 906 return NULL; | |
| 1664 | 907 |
| 4968 | 908 Py_INCREF(self); |
| 909 PyTuple_SetItem(data, 0, self); | |
| 910 | |
| 911 Py_INCREF(func); | |
| 912 PyTuple_SetItem(data, 1, func); | |
| 1664 | 913 |
| 4968 | 914 Tcl_CreateCommand(Tkapp_Interp (self), cmdName, PythonCmd, |
| 915 (ClientData) data, PythonCmdDelete); | |
| 1664 | 916 |
| 4968 | 917 Py_INCREF(Py_None); |
| 918 return Py_None; | |
| 1664 | 919 } |
| 920 | |
| 4968 | 921 |
| 922 | |
| 1664 | 923 static PyObject * |
| 924 Tkapp_DeleteCommand (self, args) | |
| 4968 | 925 PyObject *self; |
| 926 PyObject *args; | |
| 1664 | 927 { |
| 4968 | 928 char *cmdName; |
| 1664 | 929 |
| 4968 | 930 if (!PyArg_Parse(args, "s", &cmdName)) |
| 931 return NULL; | |
| 932 if (Tcl_DeleteCommand(Tkapp_Interp(self), cmdName) == -1) | |
| 933 { | |
| 934 PyErr_SetString(Tkinter_TclError, "can't delete Tcl command"); | |
| 935 return NULL; | |
| 936 } | |
| 937 Py_INCREF(Py_None); | |
| 938 return Py_None; | |
| 1664 | 939 } |
| 940 | |
| 4968 | 941 |
| 942 | |
| 1664 | 943 /** File Handler **/ |
| 944 | |
|
2123
fd5ab7e828fc
cosmetic changes so these modules will work with the strict new naming scheme
Guido van Rossum <guido@python.org>
parents:
2121
diff
changeset
|
945 static void |
| 1664 | 946 FileHandler (clientData, mask) |
| 4968 | 947 ClientData clientData; /* Is: (func, file) */ |
| 948 int mask; | |
| 1664 | 949 { |
| 4968 | 950 PyObject *func, *file, *arg, *res; |
| 1664 | 951 |
| 4968 | 952 func = PyTuple_GetItem((PyObject *) clientData, 0); |
| 953 file = PyTuple_GetItem((PyObject *) clientData, 1); | |
| 1664 | 954 |
| 4968 | 955 arg = Py_BuildValue("(Oi)", file, (long) mask); |
| 956 res = PyEval_CallObject(func, arg); | |
| 957 Py_DECREF (arg); | |
| 958 | |
| 959 if (res == NULL) { | |
| 960 errorInCmd = 1; | |
| 961 PyErr_Fetch(&excInCmd, &valInCmd, &trbInCmd); | |
| 962 } | |
| 963 Py_XDECREF(res); | |
|
1771
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
964 } |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
965 |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
966 static int |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
967 GetFileNo (file) |
| 4968 | 968 /* Either an int >= 0 or an object with a |
| 969 *.fileno() method that returns an int >= 0 | |
| 970 */ | |
| 971 PyObject *file; | |
|
1771
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
972 { |
|
2123
fd5ab7e828fc
cosmetic changes so these modules will work with the strict new naming scheme
Guido van Rossum <guido@python.org>
parents:
2121
diff
changeset
|
973 PyObject *meth, *args, *res; |
|
1771
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
974 int id; |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
975 if (PyInt_Check(file)) { |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
976 id = PyInt_AsLong(file); |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
977 if (id < 0) |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
978 PyErr_SetString(PyExc_ValueError, "invalid file id"); |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
979 return id; |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
980 } |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
981 args = PyTuple_New(0); |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
982 if (args == NULL) |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
983 return -1; |
| 4968 | 984 |
| 985 meth = PyObject_GetAttrString(file, "fileno"); | |
| 986 if (meth == NULL) { | |
| 987 Py_DECREF(args); | |
| 988 return -1; | |
| 989 } | |
| 990 | |
|
1771
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
991 res = PyEval_CallObject(meth, args); |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
992 Py_DECREF(args); |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
993 Py_DECREF(meth); |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
994 if (res == NULL) |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
995 return -1; |
| 4968 | 996 |
|
1771
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
997 if (PyInt_Check(res)) |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
998 id = PyInt_AsLong(res); |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
999 else |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
1000 id = -1; |
| 4968 | 1001 |
|
1771
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
1002 if (id < 0) |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
1003 PyErr_SetString(PyExc_ValueError, |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
1004 "invalid fileno() return value"); |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
1005 Py_DECREF(res); |
|
51c2e5a9f39c
* tkintermodule.c (*FileHandler): generalize to arbitrary file ids
Guido van Rossum <guido@python.org>
parents:
1756
diff
changeset
|
1006 return id; |
| 1664 | 1007 } |
| 1008 | |
| 4968 | 1009 |
| 1010 static PyObject* Tkapp_ClientDataDict = NULL; | |
| 1011 | |
| 1664 | 1012 static PyObject * |
| 1013 Tkapp_CreateFileHandler (self, args) | |
| 4968 | 1014 PyObject *self; |
| 1015 PyObject *args; /* Is (file, mask, func) */ | |
| 1664 | 1016 { |
| 4968 | 1017 PyObject *file, *func, *data; |
| 1018 PyObject *idkey; | |
| 1019 int mask, id; | |
|
3554
24279bafa828
Patch from the net for 4.1 file handler changes.
Guido van Rossum <guido@python.org>
parents:
3553
diff
changeset
|
1020 #if (TK_MAJOR_VERSION*1000 + TK_MINOR_VERSION) >= 4001 |
| 4968 | 1021 Tcl_File tfile; |
|
3554
24279bafa828
Patch from the net for 4.1 file handler changes.
Guido van Rossum <guido@python.org>
parents:
3553
diff
changeset
|
1022 #endif |
| 1664 | 1023 |
| 4968 | 1024 if (!Tkapp_ClientDataDict) { |
| 1025 if (!(Tkapp_ClientDataDict = PyDict_New())) | |
| 1026 return NULL; | |
| 1027 } | |
| 1664 | 1028 |
| 4968 | 1029 if (!PyArg_Parse(args, "(OiO)", &file, &mask, &func)) |
| 1030 return NULL; | |
| 1031 id = GetFileNo(file); | |
| 1032 if (id < 0) | |
| 1033 return NULL; | |
| 1034 if (!PyCallable_Check(func)) { | |
| 1035 PyErr_SetString (PyExc_TypeError, "bad argument list"); | |
| 1036 return NULL; | |
| 1037 } | |
| 1038 | |
| 1039 if (!(idkey = PyInt_FromLong(id))) | |
| 1040 return NULL; | |
| 1041 | |
| 1042 /* ClientData is: (func, file) */ | |
| 1043 data = Py_BuildValue ("(OO)", func, file); | |
| 1044 if (!data || PyDict_SetItem(Tkapp_ClientDataDict, idkey, data)) { | |
| 1045 Py_DECREF(idkey); | |
| 1046 Py_XDECREF(data); | |
| 1047 return NULL; | |
| 1048 } | |
| 1049 Py_DECREF(idkey); | |
|
1690
93e036786b17
* tkintermodule.c (Tkapp_New): Remove #ifdef WITH_APPINIT.
Guido van Rossum <guido@python.org>
parents:
1664
diff
changeset
|
1050 |
|
3554
24279bafa828
Patch from the net for 4.1 file handler changes.
Guido van Rossum <guido@python.org>
parents:
3553
diff
changeset
|
1051 #if (TK_MAJOR_VERSION*1000 + TK_MINOR_VERSION) >= 4001 |
|
4299
eb1ed743972c
Rationalize MS #ifdefs
Guido van Rossum <guido@python.org>
parents:
4139
diff
changeset
|
1052 #ifdef MS_WINDOWS |
| 4968 | 1053 /* We assume this is a socket... */ |
| 1054 tfile = Tcl_GetFile((ClientData)id, TCL_WIN_SOCKET); | |
| 3703 | 1055 #else |
| 4968 | 1056 tfile = Tcl_GetFile((ClientData)id, TCL_UNIX_FD); |
| 3703 | 1057 #endif |
| 4968 | 1058 /* Ought to check for null Tcl_File object... */ |
| 1059 Tcl_CreateFileHandler(tfile, mask, FileHandler, (ClientData) data); | |
|
3554
24279bafa828
Patch from the net for 4.1 file handler changes.
Guido van Rossum <guido@python.org>
parents:
3553
diff
changeset
|
1060 #else |
| 4968 | 1061 Tk_CreateFileHandler(id, mask, FileHandler, (ClientData) data); |
|
3554
24279bafa828
Patch from the net for 4.1 file handler changes.
Guido van Rossum <guido@python.org>
parents:
3553
diff
changeset
|
1062 #endif |
| 4968 | 1063 /* XXX fileHandlerDict */ |
| 1064 Py_INCREF (Py_None); | |
| 1065 return Py_None; | |
| 1664 | 1066 } |
| 1067 | |
| 4968 | 1068 |
| 1664 | 1069 static PyObject * |
| 1070 Tkapp_DeleteFileHandler (self, args) | |
| 4968 | 1071 PyObject *self; |
| 1072 PyObject *args; /* Args: file */ | |
| 1664 | 1073 { |
| 4968 | 1074 PyObject *file; |
| 1075 PyObject *idkey; | |
| 1076 PyObject *data; | |
| 1077 int id; | |
|
3554
24279bafa828
Patch from the net for 4.1 file handler changes.
Guido van Rossum <guido@python.org>
parents:
3553
diff
changeset
|
1078 #if (TK_MAJOR_VERSION*1000 + TK_MINOR_VERSION) >= 4001 |
| 4968 | 1079 Tcl_File tfile; |
|
3554
24279bafa828
Patch from the net for 4.1 file handler changes.
Guido van Rossum <guido@python.org>
parents:
3553
diff
changeset
|
1080 #endif |
|
24279bafa828
Patch from the net for 4.1 file handler changes.
Guido van Rossum <guido@python.org>
parents:
3553
diff
changeset
|
1081 |
| 4968 | 1082 if (!PyArg_Parse(args, "O", &file)) |
| 1083 return NULL; | |
| 1084 id = GetFileNo(file); | |
| 1085 if (id < 0) | |
| 1086 return NULL; | |
| 1087 | |
| 1088 if (!(idkey = PyInt_FromLong(id))) | |
| 1089 return NULL; | |
| 1090 | |
| 1091 /* find and free the object created in the | |
| 1092 * Tkapp_CreateFileHandler() call | |
| 1093 */ | |
| 1094 data = PyDict_GetItem(Tkapp_ClientDataDict, idkey); | |
| 1095 Py_XDECREF(data); | |
| 1096 PyDict_DelItem(Tkapp_ClientDataDict, idkey); | |
| 1097 Py_DECREF(idkey); | |
| 1664 | 1098 |
|
3554
24279bafa828
Patch from the net for 4.1 file handler changes.
Guido van Rossum <guido@python.org>
parents:
3553
diff
changeset
|
1099 #if (TK_MAJOR_VERSION*1000 + TK_MINOR_VERSION) >= 4001 |
|
4299
eb1ed743972c
Rationalize MS #ifdefs
Guido van Rossum <guido@python.org>
parents:
4139
diff
changeset
|
1100 #ifdef MS_WINDOWS |
| 4968 | 1101 /* We assume this is a socket... */ |
| 1102 tfile = Tcl_GetFile((ClientData)id, TCL_WIN_SOCKET); | |
| 3703 | 1103 #else |
| 4968 | 1104 tfile = Tcl_GetFile((ClientData)id, TCL_UNIX_FD); |
| 3703 | 1105 #endif |
| 4968 | 1106 /* Ought to check for null Tcl_File object... */ |
| 1107 Tcl_DeleteFileHandler(tfile); | |
|
3554
24279bafa828
Patch from the net for 4.1 file handler changes.
Guido van Rossum <guido@python.org>
parents:
3553
diff
changeset
|
1108 #else |
| 4968 | 1109 Tk_DeleteFileHandler(id); |
|
3554
24279bafa828
Patch from the net for 4.1 file handler changes.
Guido van Rossum <guido@python.org>
parents:
3553
diff
changeset
|
1110 #endif |
| 4968 | 1111 /* XXX fileHandlerDict */ |
| 1112 Py_INCREF (Py_None); | |
| 1113 return Py_None; | |
| 1664 | 1114 } |
| 1115 | |
| 4968 | 1116 |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1117 /**** Tktt Object (timer token) ****/ |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1118 |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1119 staticforward PyTypeObject Tktt_Type; |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1120 |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1121 typedef struct |
| 4968 | 1122 { |
| 1123 PyObject_HEAD | |
| 1124 Tk_TimerToken token; | |
| 1125 PyObject *func; | |
| 1126 } | |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1127 TkttObject; |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1128 |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1129 static PyObject * |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1130 Tktt_DeleteTimerHandler (self, args) |
| 4968 | 1131 PyObject *self; |
| 1132 PyObject *args; | |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1133 { |
| 4968 | 1134 TkttObject *v = (TkttObject *)self; |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1135 |
| 4968 | 1136 if (!PyArg_Parse(args, "")) |
| 1137 return NULL; | |
| 1138 if (v->func != NULL) { | |
| 1139 Tk_DeleteTimerHandler(v->token); | |
| 1140 PyMem_DEL(v->func); | |
| 1141 v->func = NULL; | |
| 1142 } | |
| 1143 Py_INCREF(Py_None); | |
| 1144 return Py_None; | |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1145 } |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1146 |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1147 static PyMethodDef Tktt_methods[] = |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1148 { |
| 4968 | 1149 {"deletetimerhandler", Tktt_DeleteTimerHandler}, |
| 1150 {NULL, NULL} | |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1151 }; |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1152 |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1153 static TkttObject * |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1154 Tktt_New (token, func) |
| 4968 | 1155 Tk_TimerToken token; |
| 1156 PyObject *func; | |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1157 { |
| 4968 | 1158 TkttObject *v; |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1159 |
| 4968 | 1160 v = PyObject_NEW(TkttObject, &Tktt_Type); |
| 1161 if (v == NULL) | |
| 1162 return NULL; | |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1163 |
| 4968 | 1164 v->token = token; |
| 1165 v->func = func; | |
| 1166 Py_INCREF(v->func); | |
| 1167 return v; | |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1168 } |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1169 |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1170 static void |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1171 Tktt_Dealloc (self) |
| 4968 | 1172 PyObject *self; |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1173 { |
| 4968 | 1174 PyMem_DEL (self); |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1175 } |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1176 |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1177 static int |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1178 Tktt_Print (self, fp, flags) |
| 4968 | 1179 PyObject *self; |
| 1180 FILE *fp; | |
| 1181 int flags; | |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1182 { |
| 4968 | 1183 TkttObject *v = (TkttObject *)self; |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1184 |
| 4968 | 1185 fprintf(fp, "<tktimertoken at 0x%lx%s>", (long)v, |
| 1186 v->func == NULL ? ", handler deleted" : ""); | |
| 1187 return 0; | |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1188 } |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1189 |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1190 static PyObject * |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1191 Tktt_GetAttr (self, name) |
| 4968 | 1192 PyObject *self; |
| 1193 char *name; | |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1194 { |
| 4968 | 1195 return Py_FindMethod(Tktt_methods, self, name); |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1196 } |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1197 |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1198 static PyTypeObject Tktt_Type = |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1199 { |
| 4968 | 1200 PyObject_HEAD_INIT (NULL) |
| 1201 0, /*ob_size */ | |
| 1202 "tktimertoken", /*tp_name */ | |
| 1203 sizeof (TkttObject), /*tp_basicsize */ | |
| 1204 0, /*tp_itemsize */ | |
| 1205 Tktt_Dealloc, /*tp_dealloc */ | |
| 1206 Tktt_Print, /*tp_print */ | |
| 1207 Tktt_GetAttr, /*tp_getattr */ | |
| 1208 0, /*tp_setattr */ | |
| 1209 0, /*tp_compare */ | |
| 1210 0, /*tp_repr */ | |
| 1211 0, /*tp_as_number */ | |
| 1212 0, /*tp_as_sequence */ | |
| 1213 0, /*tp_as_mapping */ | |
| 1214 0, /*tp_hash */ | |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1215 }; |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1216 |
| 4968 | 1217 |
| 1218 | |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1219 /** Timer Handler **/ |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1220 |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1221 static void |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1222 TimerHandler (clientData) |
| 4968 | 1223 ClientData clientData; |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1224 { |
| 4968 | 1225 PyObject *func = (PyObject *)clientData; |
| 1226 PyObject *res = PyEval_CallObject(func, NULL); | |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1227 |
| 4968 | 1228 if (res == NULL) { |
| 1229 errorInCmd = 1; | |
| 1230 PyErr_Fetch(&excInCmd, &valInCmd, &trbInCmd); | |
| 1231 } | |
| 1232 else | |
| 1233 Py_DECREF(res); | |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1234 } |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1235 |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1236 static PyObject * |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1237 Tkapp_CreateTimerHandler (self, args) |
| 4968 | 1238 PyObject *self; |
| 1239 PyObject *args; /* Is (milliseconds, func) */ | |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1240 { |
| 4968 | 1241 int milliseconds; |
| 1242 PyObject *func; | |
| 1243 Tk_TimerToken token; | |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1244 |
| 4968 | 1245 if (!PyArg_Parse(args, "(iO)", &milliseconds, &func)) |
| 1246 return NULL; | |
| 1247 if (!PyCallable_Check(func)) { | |
| 1248 PyErr_SetString (PyExc_TypeError, "bad argument list"); | |
| 1249 return NULL; | |
| 1250 } | |
| 1251 token = Tk_CreateTimerHandler(milliseconds, TimerHandler, | |
| 1252 (ClientData)func); | |
| 1253 | |
| 1254 return (PyObject *) Tktt_New(token, func); | |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1255 } |
|
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1256 |
| 4968 | 1257 |
| 1258 | |
| 1664 | 1259 /** Event Loop **/ |
| 1260 | |
| 1261 static PyObject * | |
| 1262 Tkapp_MainLoop (self, args) | |
| 4968 | 1263 PyObject *self; |
| 1264 PyObject *args; | |
| 1664 | 1265 { |
| 4968 | 1266 int threshold = 0; |
|
2009
392db1881190
added timer and file callbacks and global mainloop and quit fns
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
1267 |
| 4968 | 1268 if (!PyArg_ParseTuple(args, "|i", &threshold)) |
| 1269 return NULL; | |
| 1664 | 1270 |
| 4968 | 1271 quitMainLoop = 0; |
| 1272 while (Tk_GetNumMainWindows() > threshold && | |
| 1273 !quitMainLoop && | |
| 1274 !errorInCmd) | |
| 1664 | 1275 { |
| 4968 | 1276 /* XXX Ought to check for other signals! */ |
| 1277 if (PyOS_InterruptOccurred()) { | |
| 1278 PyErr_SetNone(PyExc_KeyboardInterrupt); | |
| 1279 return NULL; | |
| 1280 } | |
| 1281 Tk_DoOneEvent(0); | |
| 1664 | 1282 } |
| 4968 | 1283 quitMainLoop = 0; |
| 1664 | 1284 |
| 4968 | 1285 if (errorInCmd) { |
| 1286 errorInCmd = 0; | |
| 1287 PyErr_Restore(excInCmd, valInCmd, trbInCmd); | |
| 1288 excInCmd = valInCmd = trbInCmd = NULL; | |
| 1289 return NULL; | |
| 1290 } | |
| 1291 Py_INCREF(Py_None); | |
| 1292 return Py_None; | |
| 1664 | 1293 } |
| 1294 | |
| 1295 static PyObject * | |
|
2121
86d9e91405c8
added interface to Tk_DoOneEvent (R Lindsay Todd)
Guido van Rossum <guido@python.org>
parents:
2055
diff
changeset
|
1296 Tkapp_DoOneEvent (self, args) |
| 4968 | 1297 PyObject *self; |
| 1298 PyObject *args; | |
|
2121
86d9e91405c8
added interface to Tk_DoOneEvent (R Lindsay Todd)
Guido van Rossum <guido@python.org>
parents:
2055
diff
changeset
|
1299 { |
| 4968 | 1300 int flags = TK_ALL_EVENTS; |
| 1301 int rv; | |
|
2121
86d9e91405c8
added interface to Tk_DoOneEvent (R Lindsay Todd)
Guido van Rossum <guido@python.org>
parents:
2055
diff
changeset
|
1302 |
| 4968 | 1303 if (!PyArg_ParseTuple(args, "|i", &flags)) |
| 1304 return NULL; | |
| 1305 | |
| 1306 rv = Tk_DoOneEvent(flags); | |
| 1307 return Py_BuildValue("i", rv); | |
|
2121
86d9e91405c8
added interface to Tk_DoOneEvent (R Lindsay Todd)
Guido van Rossum <guido@python.org>
parents:
2055
diff
changeset
|
1308 } |
|
86d9e91405c8
added interface to Tk_DoOneEvent (R Lindsay Todd)
Guido van Rossum <guido@python.org>
parents:
2055
diff
changeset
|
1309 |
|
86d9e91405c8
added interface to Tk_DoOneEvent (R Lindsay Todd)
Guido van Rossum <guido@python.org>
parents:
2055
diff
changeset
|
1310 static PyObject * |
| 1664 | 1311 Tkapp_Quit (self, args) |
| 4968 | 1312 PyObject *self; |
| 1313 PyObject *args; | |
| 1664 | 1314 { |
| 1315 | |
| 4968 | 1316 if (!PyArg_Parse(args, "")) |
| 1317 return NULL; | |
| 1318 | |
| 1319 quitMainLoop = 1; | |
| 1320 Py_INCREF(Py_None); | |
| 1321 return Py_None; | |
| 1664 | 1322 } |
| 1323 | |
| 4968 | 1324 |
| 1325 | |
| 1664 | 1326 /**** Tkapp Method List ****/ |
| 1327 | |
| 1328 static PyMethodDef Tkapp_methods[] = | |
| 1329 { | |
| 4968 | 1330 {"call", Tkapp_Call}, |
| 1331 {"globalcall", Tkapp_GlobalCall}, | |
| 1332 {"eval", Tkapp_Eval}, | |
| 1333 {"globaleval", Tkapp_GlobalEval}, | |
| 1334 {"evalfile", Tkapp_EvalFile}, | |
| 1335 {"record", Tkapp_Record}, | |
| 1336 {"adderrorinfo", Tkapp_AddErrorInfo}, | |
| 1337 {"setvar", Tkapp_SetVar}, | |
| 1338 {"globalsetvar", Tkapp_GlobalSetVar}, | |
| 1339 {"getvar", Tkapp_GetVar}, | |
| 1340 {"globalgetvar", Tkapp_GlobalGetVar}, | |
| 1341 {"unsetvar", Tkapp_UnsetVar}, | |
| 1342 {"globalunsetvar", Tkapp_GlobalUnsetVar}, | |
| 1343 {"getint", Tkapp_GetInt}, | |
| 1344 {"getdouble", Tkapp_GetDouble}, | |
| 1345 {"getboolean", Tkapp_GetBoolean}, | |
| 1346 {"exprstring", Tkapp_ExprString}, | |
| 1347 {"exprlong", Tkapp_ExprLong}, | |
| 1348 {"exprdouble", Tkapp_ExprDouble}, | |
| 1349 {"exprboolean", Tkapp_ExprBoolean}, | |
| 1350 {"splitlist", Tkapp_SplitList}, | |
| 1351 {"split", Tkapp_Split}, | |
| 1352 {"merge", Tkapp_Merge}, | |
| 1353 {"createcommand", Tkapp_CreateCommand}, | |
| 1354 {"deletecommand", Tkapp_DeleteCommand}, | |
| 1355 {"createfilehandler", Tkapp_CreateFileHandler}, | |
| 1356 {"deletefilehandler", Tkapp_DeleteFileHandler}, | |
| 1357 {"createtimerhandler", Tkapp_CreateTimerHandler}, | |
| 1358 {"mainloop", Tkapp_MainLoop, 1}, | |
| 1359 {"dooneevent", Tkapp_DoOneEvent, 1}, | |
| 1360 {"quit", Tkapp_Quit}, | |
| 1361 {NULL, NULL} | |
| 1664 | 1362 }; |
| 1363 | |
| 4968 | 1364 |
| 1365 | |
| 1664 | 1366 /**** Tkapp Type Methods ****/ |
| 1367 | |
| 1368 static void | |
| 1369 Tkapp_Dealloc (self) | |
| 4968 | 1370 PyObject *self; |
| 1664 | 1371 { |
|
3413
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
1372 #ifdef NEED_TKCREATEMAINWINDOW |
| 4968 | 1373 Tk_DestroyWindow (Tkapp_Tkwin (self)); |
|
3413
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
1374 #endif |
| 4968 | 1375 Tcl_DeleteInterp (Tkapp_Interp (self)); |
| 1376 PyMem_DEL (self); | |
| 1664 | 1377 } |
| 1378 | |
| 1379 static PyObject * | |
| 1380 Tkapp_GetAttr (self, name) | |
| 4968 | 1381 PyObject *self; |
| 1382 char *name; | |
| 1664 | 1383 { |
| 4968 | 1384 return Py_FindMethod (Tkapp_methods, self, name); |
| 1664 | 1385 } |
| 1386 | |
| 1387 static PyTypeObject Tkapp_Type = | |
| 1388 { | |
| 4968 | 1389 PyObject_HEAD_INIT (NULL) |
| 1390 0, /*ob_size */ | |
| 1391 "tkapp", /*tp_name */ | |
| 1392 sizeof (TkappObject), /*tp_basicsize */ | |
| 1393 0, /*tp_itemsize */ | |
| 1394 Tkapp_Dealloc, /*tp_dealloc */ | |
| 1395 0, /*tp_print */ | |
| 1396 Tkapp_GetAttr, /*tp_getattr */ | |
| 1397 0, /*tp_setattr */ | |
| 1398 0, /*tp_compare */ | |
| 1399 0, /*tp_repr */ | |
| 1400 0, /*tp_as_number */ | |
| 1401 0, /*tp_as_sequence */ | |
| 1402 0, /*tp_as_mapping */ | |
| 1403 0, /*tp_hash */ | |
| 1664 | 1404 }; |
| 1405 | |
| 4968 | 1406 |
| 1407 | |
| 1664 | 1408 /**** Tkinter Module ****/ |
| 1409 | |
| 1410 static PyObject * | |
| 1411 Tkinter_Create (self, args) | |
| 4968 | 1412 PyObject *self; |
| 1413 PyObject *args; | |
| 1664 | 1414 { |
| 4968 | 1415 char *screenName = NULL; |
| 1416 char *baseName = NULL; | |
| 1417 char *className = NULL; | |
| 1418 int interactive = 0; | |
| 1664 | 1419 |
| 4968 | 1420 baseName = strrchr(Py_GetProgramName (), '/'); |
| 1421 if (baseName != NULL) | |
| 1422 baseName++; | |
| 1423 else | |
| 1424 baseName = Py_GetProgramName(); | |
| 1425 className = "Tk"; | |
| 1664 | 1426 |
| 4968 | 1427 if (!PyArg_ParseTuple(args, "|zssi", |
| 1428 &screenName, &baseName, &className, | |
| 1429 &interactive)) | |
| 1430 return NULL; | |
| 1664 | 1431 |
| 4968 | 1432 return (PyObject *) Tkapp_New(screenName, baseName, className, |
| 1433 interactive); | |
| 1664 | 1434 } |
| 1435 | |
| 1436 static PyMethodDef moduleMethods[] = | |
| 1437 { | |
| 4968 | 1438 {"create", Tkinter_Create, 1}, |
| 1439 {"createfilehandler", Tkapp_CreateFileHandler, 0}, | |
| 1440 {"deletefilehandler", Tkapp_DeleteFileHandler, 0}, | |
| 1441 {"createtimerhandler", Tkapp_CreateTimerHandler, 0}, | |
| 1442 {"mainloop", Tkapp_MainLoop, 1}, | |
| 1443 {"dooneevent", Tkapp_DoOneEvent, 1}, | |
| 1444 {"quit", Tkapp_Quit}, | |
| 1445 {NULL, NULL} | |
| 1664 | 1446 }; |
| 1447 | |
| 1448 #ifdef WITH_READLINE | |
| 1449 static int | |
| 1450 EventHook () | |
| 1451 { | |
| 4968 | 1452 /* XXX Reset tty */ |
| 1453 if (errorInCmd) { | |
| 1454 errorInCmd = 0; | |
| 1455 PyErr_Restore(excInCmd, valInCmd, trbInCmd); | |
| 1456 excInCmd = valInCmd = trbInCmd = NULL; | |
| 1457 PyErr_Print(); | |
| 1458 } | |
| 1459 if (Tk_GetNumMainWindows() > 0) | |
| 1460 Tk_DoOneEvent(TK_DONT_WAIT); | |
| 1461 return 0; | |
| 1664 | 1462 } |
| 1463 #endif /* WITH_READLINE */ | |
| 1464 | |
| 1465 static void | |
| 1713 | 1466 Tkinter_Cleanup () |
| 1467 { | |
| 4968 | 1468 /* This segfault with Tk 4.0 beta and seems unnecessary there as |
| 1469 * well */ | |
| 1470 | |
|
2300
d2049a1d3cc5
use PyCallable_Check; export TK_VERSION and TCL_VERSION strings;
Guido van Rossum <guido@python.org>
parents:
2150
diff
changeset
|
1471 #if TK_MAJOR_VERSION < 4 |
| 4968 | 1472 /* XXX rl_deprep_terminal is static, damned! */ |
| 1473 while (tkMainWindowList != 0) | |
| 1474 Tk_DestroyWindow(tkMainWindowList->win); | |
|
2300
d2049a1d3cc5
use PyCallable_Check; export TK_VERSION and TCL_VERSION strings;
Guido van Rossum <guido@python.org>
parents:
2150
diff
changeset
|
1475 #endif |
| 1713 | 1476 } |
| 1477 | |
| 4968 | 1478 |
| 1479 /* all errors will be checked in one fell swoop in init_tkinter() */ | |
| 1480 static void | |
| 1481 ins_long(d, name, val) | |
| 1482 PyObject *d; | |
| 1483 char *name; | |
| 1484 long val; | |
| 1485 { | |
| 1486 PyObject *v = PyInt_FromLong(val); | |
| 1487 if (v) { | |
| 1488 PyDict_SetItemString(d, name, v); | |
| 1489 Py_DECREF(v); | |
| 1490 } | |
| 1491 } | |
| 1492 static void | |
| 1493 ins_string(d, name, val) | |
| 1494 PyObject *d; | |
| 1495 char *name; | |
| 1496 char *val; | |
| 1497 { | |
| 1498 PyObject *v = PyString_FromString(val); | |
| 1499 if (v) { | |
| 1500 PyDict_SetItemString(d, name, v); | |
| 1501 Py_DECREF(v); | |
| 1502 } | |
| 1503 } | |
| 1504 | |
| 1505 | |
| 1664 | 1506 void |
|
3386
6f5feb3b4829
get rid of bogus name for init_tkinter()
Guido van Rossum <guido@python.org>
parents:
3262
diff
changeset
|
1507 init_tkinter () |
| 1664 | 1508 { |
| 4968 | 1509 static inited = 0; |
| 1713 | 1510 |
| 1664 | 1511 #ifdef WITH_READLINE |
| 4968 | 1512 extern int (*rl_event_hook) (); |
| 1664 | 1513 #endif /* WITH_READLINE */ |
| 4968 | 1514 PyObject *m, *d; |
| 1664 | 1515 |
| 4968 | 1516 Tkapp_Type.ob_type = &PyType_Type; |
| 1517 Tktt_Type.ob_type = &PyType_Type; | |
|
4091
dc946cab7b9b
Hacks to support being a Windows DLL
Guido van Rossum <guido@python.org>
parents:
4079
diff
changeset
|
1518 |
| 4968 | 1519 m = Py_InitModule("_tkinter", moduleMethods); |
| 1664 | 1520 |
| 4968 | 1521 d = PyModule_GetDict(m); |
| 1522 Tkinter_TclError = Py_BuildValue("s", "TclError"); | |
| 1523 PyDict_SetItemString(d, "TclError", Tkinter_TclError); | |
| 1524 | |
| 1525 ins_long(d, "READABLE", TK_READABLE); | |
| 1526 ins_long(d, "WRITABLE", TK_WRITABLE); | |
| 1527 ins_long(d, "EXCEPTION", TK_EXCEPTION); | |
| 1528 ins_long(d, "X_EVENTS", TK_X_EVENTS); | |
| 1529 ins_long(d, "FILE_EVENTS", TK_FILE_EVENTS); | |
| 1530 ins_long(d, "TIMER_EVENTS", TK_TIMER_EVENTS); | |
| 1531 ins_long(d, "IDLE_EVENTS", TK_IDLE_EVENTS); | |
| 1532 ins_long(d, "ALL_EVENTS", TK_ALL_EVENTS); | |
| 1533 ins_long(d, "DONT_WAIT", TK_DONT_WAIT); | |
| 1534 ins_string(d, "TK_VERSION", TK_VERSION); | |
| 1535 ins_string(d, "TCL_VERSION", TCL_VERSION); | |
| 1664 | 1536 |
| 1537 #ifdef WITH_READLINE | |
| 4968 | 1538 rl_event_hook = EventHook; |
| 1664 | 1539 #endif /* WITH_READLINE */ |
| 1540 | |
| 4968 | 1541 if (!inited) { |
| 1542 inited = 1; | |
| 1543 if (Py_AtExit(Tkinter_Cleanup) != 0) | |
| 1544 fprintf(stderr, | |
| 1545 "Tkinter: warning: cleanup procedure not registered\n"); | |
| 1546 } | |
| 1713 | 1547 |
| 4968 | 1548 if (PyErr_Occurred()) |
| 1549 Py_FatalError ("can't initialize module _tkinter"); | |
|
3240
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1550 #ifdef macintosh |
| 4968 | 1551 TclMacSetEventProc(PyMacConvertEvent); |
|
3414
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
1552 #if GENERATINGCFM |
| 4968 | 1553 mac_addlibresources(); |
|
3414
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
1554 #endif /* GENERATINGCFM */ |
|
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
1555 #endif /* macintosh */ |
| 1664 | 1556 } |
| 3120 | 1557 |
|
3414
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
1558 |
| 4968 | 1559 |
| 3120 | 1560 #ifdef macintosh |
|
3413
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
1561 |
|
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
1562 /* |
|
3414
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
1563 ** Anyone who embeds Tcl/Tk on the Mac must define panic(). |
|
3413
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
1564 */ |
|
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
1565 |
| 3120 | 1566 void |
| 1567 panic(char * format, ...) | |
| 1568 { | |
| 4968 | 1569 va_list varg; |
| 3120 | 1570 |
| 4968 | 1571 va_start(varg, format); |
| 3120 | 1572 |
| 4968 | 1573 vfprintf(stderr, format, varg); |
| 1574 (void) fflush(stderr); | |
| 3120 | 1575 |
| 4968 | 1576 va_end(varg); |
| 3120 | 1577 |
| 4968 | 1578 Py_FatalError("Tcl/Tk panic"); |
| 3120 | 1579 } |
|
3413
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
1580 |
|
3414
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
1581 /* |
|
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
1582 ** Pass events to SIOUX before passing them to Tk. |
|
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
1583 */ |
|
3413
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
1584 |
|
3414
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
1585 static int |
|
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
1586 PyMacConvertEvent(eventPtr) |
| 4968 | 1587 EventRecord *eventPtr; |
|
3413
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
1588 { |
| 4968 | 1589 if (SIOUXHandleOneEvent(eventPtr)) |
| 1590 return 0; /* Nothing happened to the Tcl event queue */ | |
| 1591 return TkMacConvertEvent(eventPtr); | |
|
3413
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
1592 } |
|
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
1593 |
|
5695
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1594 #ifdef USE_GUSI |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1595 /* |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1596 * For Python we have to override this routine (from TclMacNotify), |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1597 * since we use GUSI for our sockets, not Tcl streams. Hence, we have |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1598 * to use GUSI select to see whether our socket is ready. Note that |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1599 * createfilehandler (above) sets the type to TCL_UNIX_FD for our |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1600 * files and sockets. |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1601 * |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1602 * NOTE: this code was lifted from Tcl 7.6, it may need to be modified |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1603 * for other versions. */ |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1604 |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1605 int |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1606 Tcl_FileReady(file, mask) |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1607 Tcl_File file; /* File handle for a stream. */ |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1608 int mask; /* OR'ed combination of TCL_READABLE, |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1609 * TCL_WRITABLE, and TCL_EXCEPTION: |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1610 * indicates conditions caller cares about. */ |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1611 { |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1612 int type; |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1613 int fd; |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1614 |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1615 fd = (int) Tcl_GetFileInfo(file, &type); |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1616 |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1617 if (type == TCL_MAC_SOCKET) { |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1618 return TclMacSocketReady(file, mask); |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1619 } else if (type == TCL_MAC_FILE) { |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1620 /* |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1621 * Under the Macintosh, files are always ready, so we just |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1622 * return the mask that was passed in. |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1623 */ |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1624 |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1625 return mask; |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1626 } else if (type == TCL_UNIX_FD) { |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1627 fd_set readset, writeset, excset; |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1628 struct timeval tv; |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1629 |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1630 FD_ZERO(&readset); |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1631 FD_ZERO(&writeset); |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1632 FD_ZERO(&excset); |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1633 |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1634 if ( mask & TCL_READABLE ) FD_SET(fd, &readset); |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1635 if ( mask & TCL_WRITABLE ) FD_SET(fd, &writeset); |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1636 if ( mask & TCL_EXCEPTION ) FD_SET(fd, &excset); |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1637 |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1638 tv.tv_sec = tv.tv_usec = 0; |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1639 if ( select(fd+1, &readset, &writeset, &excset, &tv) <= 0 ) |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1640 return 0; |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1641 |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1642 mask = 0; |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1643 if ( FD_ISSET(fd, &readset) ) mask |= TCL_READABLE; |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1644 if ( FD_ISSET(fd, &writeset) ) mask |= TCL_WRITABLE; |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1645 if ( FD_ISSET(fd, &excset) ) mask |= TCL_EXCEPTION; |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1646 |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1647 return mask; |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1648 } |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1649 |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1650 return 0; |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1651 } |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1652 #endif /* USE_GUSI */ |
|
02ea9d021427
Mac hack to make select() work again...
Guido van Rossum <guido@python.org>
parents:
5437
diff
changeset
|
1653 |
|
3414
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
1654 #if GENERATINGCFM |
|
3413
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
1655 |
|
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
1656 /* |
|
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
1657 ** Additional Mac specific code for dealing with shared libraries. |
|
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
1658 */ |
|
3262
bfb63b45ff0f
Initialize GUSI on the mac.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3240
diff
changeset
|
1659 |
|
3413
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
1660 #include <Resources.h> |
|
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
1661 #include <CodeFragments.h> |
|
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
1662 |
|
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
1663 static int loaded_from_shlib = 0; |
|
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
1664 static FSSpec library_fss; |
| 3120 | 1665 |
|
3240
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1666 /* |
|
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1667 ** If this module is dynamically loaded the following routine should |
|
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1668 ** be the init routine. It takes care of adding the shared library to |
|
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1669 ** the resource-file chain, so that the tk routines can find their |
|
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1670 ** resources. |
|
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1671 */ |
|
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1672 OSErr pascal |
|
5360
f858038b64c2
Adapt Mac specific code to new universal headers (I think -- this is
Guido van Rossum <guido@python.org>
parents:
5197
diff
changeset
|
1673 init_tkinter_shlib(CFragInitBlockPtr data) |
|
3240
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1674 { |
|
4139
010344b4a616
Call __initialize(), not __sinit() on Mac dynamic loading entry.
Guido van Rossum <guido@python.org>
parents:
4091
diff
changeset
|
1675 __initialize(); |
|
3240
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1676 if ( data == nil ) return noErr; |
|
5360
f858038b64c2
Adapt Mac specific code to new universal headers (I think -- this is
Guido van Rossum <guido@python.org>
parents:
5197
diff
changeset
|
1677 if ( data->fragLocator.where == kDataForkCFragLocator ) { |
|
3240
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1678 library_fss = *data->fragLocator.u.onDisk.fileSpec; |
|
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1679 loaded_from_shlib = 1; |
|
5360
f858038b64c2
Adapt Mac specific code to new universal headers (I think -- this is
Guido van Rossum <guido@python.org>
parents:
5197
diff
changeset
|
1680 } else if ( data->fragLocator.where == kResourceCFragLocator ) { |
|
3240
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1681 library_fss = *data->fragLocator.u.inSegs.fileSpec; |
|
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1682 loaded_from_shlib = 1; |
|
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1683 } |
|
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1684 return noErr; |
|
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1685 } |
|
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1686 |
|
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1687 /* |
|
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1688 ** Insert the library resources into the search path. Put them after |
|
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1689 ** the resources from the application. Again, we ignore errors. |
|
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1690 */ |
|
3413
2fe7d489654e
Changes to make it work with Tcl/Tk beta 1.
Guido van Rossum <guido@python.org>
parents:
3386
diff
changeset
|
1691 static |
|
3240
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1692 mac_addlibresources() |
|
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1693 { |
|
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1694 if ( !loaded_from_shlib ) |
|
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1695 return; |
|
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1696 (void)FSpOpenResFile(&library_fss, fsRdPerm); |
|
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1697 } |
|
f7fd85b32a7d
Fix to load needed resources on a mac
Jack Jansen <jack.jansen@cwi.nl>
parents:
3231
diff
changeset
|
1698 |
|
3414
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
1699 #endif /* GENERATINGCFM */ |
|
098cbd6d196e
Changes needed to build with Tcl/Tk beta 2!
Guido van Rossum <guido@python.org>
parents:
3413
diff
changeset
|
1700 #endif /* macintosh */ |
