如何添加Tkinter支持PIL Python库

编程入门 行业动态 更新时间:2024-10-27 09:33:25
本文介绍了如何添加Tkinter支持PIL Python库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

好吧,据说PIL应该能够自动与Tkinter一起工作,但我的不是。我在Imaging目录Tk目录中找到此文本文件。

Okay, well supposedly PIL is supposed to be able to work with Tkinter automatically, but mine is not. I found this text file in the Imaging directories Tk directory.

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的标志设置等等。

Unfortunately I have no idea how to do any of this, and I couldn't find any guides online. Can someone please walk me through how I compile Python's _tkinter.c with the flags set and so on?

推荐答案

什么版本的Python和PIL是你使用(和在什么平台等)?所有合理的最近的版本应该已经支持所有这些必需的选项(与setup.py以及Modules / Setup.dict) - 例如,包括tkappinit.c等 - 所以很难知道什么建议在真空。此外,如何编译东西(假设你确实需要)可以非常依赖于平台,所以如果你需要任何重新编译(不太可能是这样),知道你的平台可能很重要。

What versions of Python and PIL are you using (and on what platform, etc)? All reasonably recent versions should already support all of these required options (with setup.py as well as Modules/Setup.dict) -- e.g., including tkappinit.c etc -- so it's particularly hard to know what to suggest "in a vacuum". Also, how to compile things (supposing you do need to) can be very platform-dependent, so in case you do need any recompiling (unlikely as that may be), knowing your platform can be important.

更多推荐

如何添加Tkinter支持PIL Python库

本文发布于:2023-06-09 04:14:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/595025.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Tkinter   PIL   Python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!