Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3e819a7

Browse files
committed
Compatibility with Tcl/Tk 8.0b*.
1 parent f4e32c7 commit 3e819a7

1 file changed

Lines changed: 28 additions & 14 deletions

File tree

Modules/_tkinter.c

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,23 @@ PERFORMANCE OF THIS SOFTWARE.
5656
#include <tcl.h>
5757
#include <tk.h>
5858

59+
#if TK_MAJOR_VERSION < 4
60+
#error "Tk 3.x is not supported"
61+
#endif
62+
63+
#define TKMAJORMINOR (TK_MAJOR_VERSION*1000 + TK_MINOR_VERSION)
64+
5965
extern char *Py_GetProgramName ();
6066

61-
/* Internal declarations from tkInt.h. */
62-
#if (TK_MAJOR_VERSION*1000 + TK_MINOR_VERSION) >= 4001
67+
#if TKMAJORMINOR >= 4001
6368
extern int Tk_GetNumMainWindows();
6469
#else
70+
/* Internal declarations from tkInt.h. */
6571
extern int tk_NumMainWindows;
6672
#define Tk_GetNumMainWindows() (tk_NumMainWindows)
6773
#define NEED_TKCREATEMAINWINDOW 1
6874
#endif
6975

70-
#if TK_MAJOR_VERSION < 4
71-
#error "Tk 3.x is not supported"
72-
#endif
73-
7476
#ifdef macintosh
7577

7678
/*
@@ -1018,8 +1020,10 @@ Tkapp_CreateFileHandler (self, args)
10181020
PyObject *file, *func, *data;
10191021
PyObject *idkey;
10201022
int mask, id;
1021-
#if (TK_MAJOR_VERSION*1000 + TK_MINOR_VERSION) >= 4001
1023+
#if TKMAJORMINOR < 8000
1024+
#if TKMAJORMINOR >= 4001
10221025
Tcl_File tfile;
1026+
#endif
10231027
#endif
10241028

10251029
if (!Tkapp_ClientDataDict) {
@@ -1049,18 +1053,22 @@ Tkapp_CreateFileHandler (self, args)
10491053
}
10501054
Py_DECREF(idkey);
10511055

1052-
#if (TK_MAJOR_VERSION*1000 + TK_MINOR_VERSION) >= 4001
1056+
#if TKMAJORMINOR < 8000
1057+
#if TKMAJORMINOR >= 4001
10531058
#ifdef MS_WINDOWS
10541059
/* We assume this is a socket... */
10551060
tfile = Tcl_GetFile((ClientData)id, TCL_WIN_SOCKET);
1056-
#else
1061+
#else /* !MS_WINDOWS */
10571062
tfile = Tcl_GetFile((ClientData)id, TCL_UNIX_FD);
1058-
#endif
1063+
#endif /* !MS_WINDOWS */
10591064
/* Ought to check for null Tcl_File object... */
10601065
Tcl_CreateFileHandler(tfile, mask, FileHandler, (ClientData) data);
1061-
#else
1066+
#else /* ! >= 4001 */
10621067
Tk_CreateFileHandler(id, mask, FileHandler, (ClientData) data);
1063-
#endif
1068+
#endif /* ! >= 4001 */
1069+
#else /* ! < 8000 */
1070+
Tcl_CreateFileHandler(id, mask, FileHandler, (ClientData) data);
1071+
#endif /* < 8000 */
10641072
/* XXX fileHandlerDict */
10651073
Py_INCREF (Py_None);
10661074
return Py_None;
@@ -1076,8 +1084,10 @@ Tkapp_DeleteFileHandler (self, args)
10761084
PyObject *idkey;
10771085
PyObject *data;
10781086
int id;
1079-
#if (TK_MAJOR_VERSION*1000 + TK_MINOR_VERSION) >= 4001
1087+
#if TKMAJORMINOR < 8000
1088+
#if TKMAJORMINOR >= 4001
10801089
Tcl_File tfile;
1090+
#endif
10811091
#endif
10821092

10831093
if (!PyArg_Parse(args, "O", &file))
@@ -1097,7 +1107,8 @@ Tkapp_DeleteFileHandler (self, args)
10971107
PyDict_DelItem(Tkapp_ClientDataDict, idkey);
10981108
Py_DECREF(idkey);
10991109

1100-
#if (TK_MAJOR_VERSION*1000 + TK_MINOR_VERSION) >= 4001
1110+
#if TKMAJORMINOR < 8000
1111+
#if TKMAJORMINOR >= 4001
11011112
#ifdef MS_WINDOWS
11021113
/* We assume this is a socket... */
11031114
tfile = Tcl_GetFile((ClientData)id, TCL_WIN_SOCKET);
@@ -1108,6 +1119,9 @@ Tkapp_DeleteFileHandler (self, args)
11081119
Tcl_DeleteFileHandler(tfile);
11091120
#else
11101121
Tk_DeleteFileHandler(id);
1122+
#endif
1123+
#else
1124+
Tcl_DeleteFileHandler(id);
11111125
#endif
11121126
/* XXX fileHandlerDict */
11131127
Py_INCREF (Py_None);

0 commit comments

Comments
 (0)