mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Merge pull request #6549 from radarhere/interp
This commit is contained in:
commit
9c72a6d9a4
|
@ -68,21 +68,18 @@ def _pyimagingtkcall(command, photo, id):
|
||||||
# may raise an error if it cannot attach to Tkinter
|
# may raise an error if it cannot attach to Tkinter
|
||||||
from . import _imagingtk
|
from . import _imagingtk
|
||||||
|
|
||||||
try:
|
if hasattr(tk, "interp"):
|
||||||
if hasattr(tk, "interp"):
|
# Required for PyPy, which always has CFFI installed
|
||||||
# Required for PyPy, which always has CFFI installed
|
from cffi import FFI
|
||||||
from cffi import FFI
|
|
||||||
|
|
||||||
ffi = FFI()
|
ffi = FFI()
|
||||||
|
|
||||||
# PyPy is using an FFI CDATA element
|
# PyPy is using an FFI CDATA element
|
||||||
# (Pdb) self.tk.interp
|
# (Pdb) self.tk.interp
|
||||||
# <cdata 'Tcl_Interp *' 0x3061b50>
|
# <cdata 'Tcl_Interp *' 0x3061b50>
|
||||||
_imagingtk.tkinit(int(ffi.cast("uintptr_t", tk.interp)), 1)
|
_imagingtk.tkinit(int(ffi.cast("uintptr_t", tk.interp)))
|
||||||
else:
|
else:
|
||||||
_imagingtk.tkinit(tk.interpaddr(), 1)
|
_imagingtk.tkinit(tk.interpaddr())
|
||||||
except AttributeError:
|
|
||||||
_imagingtk.tkinit(id(tk), 0)
|
|
||||||
tk.call(command, photo, id)
|
tk.call(command, photo, id)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,33 +23,16 @@ TkImaging_Init(Tcl_Interp *interp);
|
||||||
extern int
|
extern int
|
||||||
load_tkinter_funcs(void);
|
load_tkinter_funcs(void);
|
||||||
|
|
||||||
/* 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 *
|
static PyObject *
|
||||||
_tkinit(PyObject *self, PyObject *args) {
|
_tkinit(PyObject *self, PyObject *args) {
|
||||||
Tcl_Interp *interp;
|
Tcl_Interp *interp;
|
||||||
|
|
||||||
PyObject *arg;
|
PyObject *arg;
|
||||||
int is_interp;
|
if (!PyArg_ParseTuple(args, "O", &arg)) {
|
||||||
if (!PyArg_ParseTuple(args, "Oi", &arg, &is_interp)) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_interp) {
|
interp = (Tcl_Interp *)PyLong_AsVoidPtr(arg);
|
||||||
interp = (Tcl_Interp *)PyLong_AsVoidPtr(arg);
|
|
||||||
} else {
|
|
||||||
TkappObject *app;
|
|
||||||
/* Do it the hard way. This will break if the TkappObject
|
|
||||||
layout changes */
|
|
||||||
app = (TkappObject *)PyLong_AsVoidPtr(arg);
|
|
||||||
interp = app->interp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This will bomb if interp is invalid... */
|
/* This will bomb if interp is invalid... */
|
||||||
TkImaging_Init(interp);
|
TkImaging_Init(interp);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user