Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 !

like image 236
jean Avatar asked Nov 05 '22 02:11

jean


2 Answers

The tkinter ports depend on tk, but the tk port uses the x11 variant by default. Solved by installing the quartz variant instead. (Remove tkinter and tk port first, then install tk quartz variant using command below, then install tkinter again)

sudo port install tk -x11 +quartz

  • -x11 disables the default x11 variant
  • +quartz enables the quartz variant

More info on variants: https://guide.macports.org/#using.variants

like image 160
vin047 Avatar answered Nov 15 '22 05:11

vin047


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

like image 20
Walle Cyril Avatar answered Nov 15 '22 04:11

Walle Cyril