2
好吧,據說PIL應該能夠自動與Tkinter一起工作,但我的不是。我在映像目錄Tk目錄中找到了這個文本文件。如何添加Tkinter支持PIL Python庫
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和設置標誌等嗎?
我在Mac OS X 10.6上使用Python 2.6.5和PIL 1.1.7(最新的PIL)。我使用setup.py安裝了PIL,除了當我嘗試將它與Tk一起使用時,PIL工作。 – Dylan 2010-07-08 14:55:12
這很奇怪,因爲我也有一臺運行OS X 10.6和Python 2.6的臺式機Mac,而帶Tk的PIL在這方面效果很好。 (它不在使用的計算機是MacBook Pro)。我在桌面上安裝PIL的方式與我在MacBook上的方式不同,但不幸的是,我不記得我是如何做到的。 – Dylan 2010-07-08 16:28:11
您是否也在桌面上使用2.6.5,或者使用不同的2.6,例如Apple提供的2.6?也許這可以解釋它... – 2010-07-08 17:14:02