Use no-X11 tkinter with python (installed through macports)

会有一股神秘感。 提交于 2019-12-10 14:12:34

问题


I have installed Python 2.7 and some useful libraries (like Python Image Library) through MacPorts. Everything is OK.

Now, I want to use Tkinter. The problem is that the version uses X11 (and I do not want to use X11).

If I switch to the python installed by Apple (/usr/bin/python instead of /opt/local/bin/python), Tkinter is OK (no X11 required) but of course, I missed the various libraries installed through MacPorts.

My question is : "How could I use the no X11 Tkinter with the Python 2.7 installed through MacPorts" ?

Thanks in advance !


回答1:


This is a known problem, you can check this page to sove it https://www.python.org/download/mac/tcltk




回答2:


Quartz is no longer shipped with OS X.

MacPorts don't ship Cocoa tkinter version. Even latest py36-tkinter depends on tk which depends on quartz or x11.

From The Python Tkinter Page (https://www.python.org/download/mac/tcltk):

How Python Chooses Which Tk Library To Use

64-bit/32-bit Mac OS X installers for Python 3.6.x, 3.5.x, and 2.7.x dynamically link to Tcl/Tk 8.5 frameworks.

32-bit-only Python installers for Mac OS X dynamically link to Tcl/Tk 8.4 frameworks.

[...] dynamic linker looks first in /Library/Frameworks for Tcl and Tk frameworks [...] then in /System/Library/Frameworks [...]

As of my test, this is not the behavior of MacPorts' Python.

So my solution was to install Python from python.org.



来源:https://stackoverflow.com/questions/10045631/use-no-x11-tkinter-with-python-installed-through-macports

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!