Как добавить поддержку Tkinter для библиотеки PIL Python - PullRequest
2 голосов
/ 08 июля 2010

Хорошо, предположительно, PIL должен работать с Tkinter автоматически, а у меня нет.Я нашел этот текстовый файл в каталоге Tk каталогов Imaging.

Using PIL With Tkinter 

Starting with 1.0 final (release candidate 2 and later, to be
precise), PIL can attach itself to Tkinter in flight.  As a result,
you no longer need to rebuild the Tkinter extension to be able to
use PIL.

However, if you cannot get the this to work on your platform, you
can do it in the old way:

* Adding Tkinter support

1. Compile Python's _tkinter.c with the WITH_APPINIT and WITH_PIL
   flags set, and link it with tkImaging.c and tkappinit.c.  To
   do this, copy the former to the Modules directory, and edit
   the _tkinter line in Setup (or Setup.in) according to the
   instructions in that file.

   NOTE: if you have an old Python version, the tkappinit.c
   file is not included by default.  If this is the case, you
   will have to add the following lines to tkappinit.c, after
   the MOREBUTTONS stuff:

  {
      extern void TkImaging_Init(Tcl_Interp* interp);
      TkImaging_Init(interp);
  }

   This registers a Tcl command called "PyImagingPhoto", which is
   use to communicate between PIL and Tk's PhotoImage handler.

   You must also change the _tkinter line in Setup (or Setup.in)
   to something like:

   _tkinter _tkinter.c tkImaging.c tkappinit.c -DWITH_APPINIT
  -I/usr/local/include -L/usr/local/lib -ltk8.0 -ltcl8.0 -lX11

К сожалению, я понятия не имею, как это сделать, и я не смог найти никаких руководств в Интернете.Может кто-нибудь рассказать мне, как я собираю Python _tkinter.c с установленными флагами и так далее?

1 Ответ

0 голосов
/ 08 июля 2010

Какие версии Python и PIL вы используете (и на какой платформе и т. Д.)? Все разумно последние версии должны уже поддерживать все эти обязательные опции (с помощью setup.py, а также Modules / Setup.dict) - например, включая tkappinit.c и т. Д., Поэтому особенно трудно понять, что предложить "в вакууме". ». Кроме того, способы компиляции (предположим, что вам это нужно) могут сильно зависеть от платформы, поэтому в случае, если вам нужна какая-либо перекомпиляция (маловероятно, что это может быть), знание вашей платформы может быть важным.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...