IMac – Python program does not display correctly on 10.13, but works on old MacBook

high sierraimacpython

I asked this question https://stackoverflow.com/questions/49955313/toplevel-does-not-create-new-independent-windows-on-macos on Stack Overflow, thinking it was a Python programming problem.

Since then, a number of users have reported no issue, and I installed Python 3.6.5 on an old MacBook, running 10.12.6 and the code runs as expected.

Can anyone suggest why it does not work on my new iMac (Retina 4K, 21.5-inch, 2017) running 10.13.4 and more importantly what I can do to change this.

The program also fails to run correctly on a 2011 MacBook Pro running 10.13.3 under Python 3.6.4

The following show the display, and after resizing.

initial

resized

I can drag the 3 Toplevel() windows on screen, and they then display normally.

Running the program on Linux Python 3.5.3 shows:-

Linux


I upgraded to https://www.python.org/ftp/python/3.6.5/python-3.6.5-macosx10.9.pkg (which has an included version of Tcl/Tk 8.6) on both the 2011 MacBook Pro and iMac (Retina 4K, 21.5-inch, 2017) which both exhibited the same problem, so it would seem to be a problem with the Python interface to macOS 10.13

Best Answer

I currently have the Anaconda version of Python 3.5.4 installed on 10.13.4 and python3 test.py at the shell prompt gave me the expected result.

I can only suggest that you have a broken tk/tcl install somewhere. This is probably due to the problems mentioned on this page. I would suggest uninstalling all versions of Python 3 and then installing either the Anaconda version or the Homebrew version. I prefer the Anaconda version as it allows me to easily install Jupyter and they look after these sort of compatibility problems well.