Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Imaging/_imagingtk.c
diff options
context:
space:
mode:
Diffstat (limited to 'Imaging/_imagingtk.c')
-rw-r--r--Imaging/_imagingtk.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/Imaging/_imagingtk.c b/Imaging/_imagingtk.c
new file mode 100644
index 0000000..5e8a94a
--- /dev/null
+++ b/Imaging/_imagingtk.c
@@ -0,0 +1,71 @@
+/*
+ * The Python Imaging Library.
+ * $Id: _imagingtk.c 1756 2004-03-28 17:15:33Z fredrik $
+ *
+ * tkinter hooks
+ *
+ * history:
+ * 99-07-26 fl created
+ * 99-08-15 fl moved to its own support module
+ *
+ * Copyright (c) Secret Labs AB 1999.
+ *
+ * See the README file for information on usage and redistribution.
+ */
+
+
+#include "Python.h"
+#include "Imaging.h"
+
+#include "tk.h"
+
+/* must link with Tk/tkImaging.c */
+extern void TkImaging_Init(Tcl_Interp* interp);
+
+/* copied from _tkinter.c (this isn't as bad as it may seem: for new
+ versions, we use _tkinter's interpaddr hook instead, and all older
+ versions use this structure layout) */
+
+typedef struct {
+ PyObject_HEAD
+ Tcl_Interp* interp;
+} TkappObject;
+
+static PyObject*
+_tkinit(PyObject* self, PyObject* args)
+{
+ Tcl_Interp* interp;
+
+ long arg;
+ int is_interp;
+ if (!PyArg_ParseTuple(args, "li", &arg, &is_interp))
+ return NULL;
+
+ if (is_interp)
+ interp = (Tcl_Interp*) arg;
+ else {
+ TkappObject* app;
+ /* Do it the hard way. This will break if the TkappObject
+ layout changes */
+ app = (TkappObject*) arg;
+ interp = app->interp;
+ }
+
+ /* This will bomb if interp is invalid... */
+ TkImaging_Init(interp);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMethodDef functions[] = {
+ /* Tkinter interface stuff */
+ {"tkinit", (PyCFunction)_tkinit, 1},
+ {NULL, NULL} /* sentinel */
+};
+
+DL_EXPORT(void)
+init_imagingtk(void)
+{
+ Py_InitModule("_imagingtk", functions);
+}