2010-07-31 06:52:47 +04:00
|
|
|
/*
|
|
|
|
* The Python Imaging Library.
|
|
|
|
*
|
|
|
|
* tkinter hooks
|
|
|
|
*
|
|
|
|
* history:
|
2020-05-01 15:08:57 +03:00
|
|
|
* 99-07-26 fl created
|
|
|
|
* 99-08-15 fl moved to its own support module
|
2010-07-31 06:52:47 +04:00
|
|
|
*
|
|
|
|
* Copyright (c) Secret Labs AB 1999.
|
|
|
|
*
|
|
|
|
* See the README file for information on usage and redistribution.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Python.h"
|
2020-09-16 08:10:28 +03:00
|
|
|
#include "libImaging/Imaging.h"
|
2010-07-31 06:52:47 +04:00
|
|
|
|
2020-09-29 12:54:57 +03:00
|
|
|
#include "Tk/_tkmini.h"
|
2010-07-31 06:52:47 +04:00
|
|
|
|
|
|
|
/* must link with Tk/tkImaging.c */
|
|
|
|
extern void
|
|
|
|
TkImaging_Init(Tcl_Interp *interp);
|
2016-05-27 01:05:53 +03:00
|
|
|
extern int
|
|
|
|
load_tkinter_funcs(void);
|
2010-07-31 06:52:47 +04:00
|
|
|
|
2013-07-01 02:42:19 +04:00
|
|
|
static PyObject *
|
2010-07-31 06:52:47 +04:00
|
|
|
_tkinit(PyObject *self, PyObject *args) {
|
|
|
|
Tcl_Interp *interp;
|
|
|
|
|
2017-01-17 17:20:39 +03:00
|
|
|
PyObject *arg;
|
2022-08-30 02:21:24 +03:00
|
|
|
if (!PyArg_ParseTuple(args, "O", &arg)) {
|
2010-07-31 06:52:47 +04:00
|
|
|
return NULL;
|
2020-05-10 12:56:36 +03:00
|
|
|
}
|
2010-07-31 06:52:47 +04:00
|
|
|
|
2022-08-30 02:21:24 +03:00
|
|
|
interp = (Tcl_Interp *)PyLong_AsVoidPtr(arg);
|
2010-07-31 06:52:47 +04:00
|
|
|
|
|
|
|
/* 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 */
|
|
|
|
};
|
|
|
|
|
2012-10-14 08:47:30 +04:00
|
|
|
PyMODINIT_FUNC
|
|
|
|
PyInit__imagingtk(void) {
|
|
|
|
static PyModuleDef module_def = {
|
|
|
|
PyModuleDef_HEAD_INIT,
|
|
|
|
"_imagingtk", /* m_name */
|
|
|
|
NULL, /* m_doc */
|
|
|
|
-1, /* m_size */
|
|
|
|
functions, /* m_methods */
|
|
|
|
};
|
2016-05-27 01:05:53 +03:00
|
|
|
PyObject *m;
|
|
|
|
m = PyModule_Create(&module_def);
|
2023-03-11 16:11:48 +03:00
|
|
|
if (load_tkinter_funcs() != 0) {
|
|
|
|
Py_DECREF(m);
|
2023-03-18 14:47:04 +03:00
|
|
|
return NULL;
|
2023-03-11 16:11:48 +03:00
|
|
|
}
|
|
|
|
return m;
|
2012-10-14 08:47:30 +04:00
|
|
|
}
|