2

I'm writing a python program using turtle graphics on When the turtle window opens up it is glitching and blinking but now showing any graphics.

import turtle

turtle.up()
turtle.write("hello world")
turtle.done()

glitching turtle screen

There's a similar unresolved question on reddit.

I'm not sure what is wrong and how to fix it.

MacOS Mojave 12.3
Python 3.10.6
PythonTurtle == 0.3.2

Edit: This snippet works on ubuntu

twitu
  • 553
  • 6
  • 12

1 Answers1

1

Brutal fix. ‍

Some combination of MacOS version, Python version and tkinter configuration create this issue.

I followed the steps in this SO answer.

However there is a small change, with MacOS Mojave 12.3, Python 3.8.13 must be installed. SO answer

So the updated steps are below.

brew install tcl-tk
env \
  PATH="$(brew --prefix tcl-tk)/bin:$PATH" \
  LDFLAGS="-L$(brew --prefix tcl-tk)/lib" \
  CPPFLAGS="-I$(brew --prefix tcl-tk)/include" \
  PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig" \
  CFLAGS="-I$(brew --prefix tcl-tk)/include" \
  PYTHON_CONFIGURE_OPTS="--with-tcltk-includes='-I$(brew --prefix tcl-tk)/include' --with-tcltk-libs='-L$(brew --prefix tcl-tk)/lib -ltcl8.6 -ltk8.6'" \
  pyenv install 3.8.13
twitu
  • 553
  • 6
  • 12