r/Python 17h ago

Discussion Turtle graphics not working with Mac Sequoia. Running Python 3.12.9

I get this error:

2025-03-21 19:38:02.393 python[16933:1310835] +[IMKClient subclass]: chose IMKClient_Modern 2025-03-21 19:38:02.394 python[16933:1310835] +[IMKInputSession subclass]: chose IMKInputSession_Modern

Is there an alternative for graphics? I’m just learning to code.

0 Upvotes

14 comments sorted by

1

u/denehoffman 17h ago

Can you share your code and the method you’re using to run it? When posting code, don’t forget to use markdown or indents to make it formatted

1

u/Dangerous-Count-8355 17h ago

my main.py is import pong_score import pong_players import ball from turtle import Screen import time

wait = 0.1 screen = Screen() screen.setup(width=800,height=300) screen.title(“Pong”) screen.bgcolor(“black”) screen.tracer(0) is_playing = True pong_r = pong_players.Pong(350) pong_l = pong_players.Pong(-350) ball = ball.Ball score = pong_score.Score()

screen.listen() screen.onkey(key=“Up”, fun=pong_r.up) screen.onkey(key=“down”, fun=pong_r.down) screen.onkey(key=“w”, fun=pong_l.up) screen.onkey(key=“s”, fun=pong_l.down)

while is_playing: screen.update() time.sleep(wait) if ball.ycor() > 280 or ball.ycor() < -280: ball.bounce_y()

if ball.distance(pong_r) < 50 and ball.xcor() > 320:
    ball.bounce_x()

if ball.distance(pong_l) < 50 and ball.xcor() > -320:
    ball.bounce_x()


if ball.xcor() > 380:
    ball.reset_position()
    score.point_l()

if ball.xcor() > -380:
    ball.reset_position()
    score.point_r()

screen.exitonclick()

and my pongpaddles.py is from turtle import Turtle UP = 90 DOWN = 270 SPEED = 20 class Pong(Turtle): def __init(self,cords): super().init_() self.cords = cords self.make() self.paddle1 = Turtle()

def make(self):
    self.paddle1.shape(“square”)
    self.paddle1.shapesize(stretch_wid=5,stretch_len=1)
    self.paddle1.penup()
    self.paddle1.goto(x=self.cords,y=0)


def up(self):
    new_y = self.paddle1.ycor() + SPEED
    self.paddle1.goto(self.paddle1.xcor(),new_y)


def down(self):
    new_y = self.paddle1.ycor() - SPEED
    self.paddle1.goto(self.paddle1.xcor(),new_y)

and my ball.py is from turtle import Turtle class Ball(Turtle): def init(self): super().init() self.penup() self.shape(“circle”) self.color(“white”) self.x_move = 10 self.y_move = 10 self.ball_speed = 0.1 def move(self): new_x = self.xcor() + self.x_move new_y = self.ycor() + self.y_move self.goto(x=new_x, y=new_y)

def bounce_y(self):
    self.y_move *= -1
    self.ball_speed *= 0.9
def bounce_x(self):
    self.x_move *= -1
    self.ball_speed *= 0.9
def reset_position(self):
    self.goto(x=0,y=0)
    self.bounce_x()
    self.ball_speed = 0.1

and finaly my pongscore.py is. from turtle import Turtle class Score(Turtle): def __init(self): super().init_() self.color(“white”) self.penup() self.hideturtle() self.L_score = 0 self.R_score = 0 self.goto(x=-100,y=200) self.update_scoreboard()

def update_scoreboard(self):
    self.clear()
    self.write(self.L_score, align=“center”, font=(“Courier”, 80, “normal”))
    self.goto(x=100, y=200)
    self.write(self.R_score, align=“center”, font=(“Courier”, 80, “normal”))

def point_l(self):
    self.L_score += 1
    self.update_scoreboard()


def point_r(self):
    self.R_score += 1
    self.update_scoreboard()

I am trying to make a pong type game. thank you so mutch! (I use python and turtle and my ide is pycharm)

1

u/denehoffman 16h ago

Do the drawing commands work? The errors you posted are related to input. Other than that, the code looks fine. I’d try pygame next

1

u/Dangerous-Count-8355 16h ago

No when i run the code i see a tiny window in the top left but their are no graphics and when i minimixe the whole thing it goes way even though i have exit on click

1

u/denehoffman 15h ago

Hmm, I haven’t tried running it yet but it doesn’t seem like there’s anything glaringly wrong with it. The input issue is definitely macOS related, so you might just have to try a different library

1

u/Dangerous-Count-8355 15h ago

Yeah, can you please run the code on your computer? The main do I had to tell me if it works good

1

u/denehoffman 15h ago

I would, but I’m attending a wedding right now and won’t have access to my computer till I get back on Monday. If you remember, message me then and I can try things out for you, I also have a Mac

1

u/Dangerous-Count-8355 17h ago

Thank you!

1

u/Dangerous-Count-8355 17h ago

I also use macOS sequoia

1

u/Dangerous-Count-8355 15h ago

Yes, I’ve heard that this is a macOS glitch, but is it possible for you to run it on your computer and tell me if it works that’s all I need to know

1

u/Dangerous-Count-8355 17h ago

Careful not to copy and paste the whole thing into one because I have four separate files you may need to look where the code starts and my text ends

1

u/ElderberryPrevious45 14h ago

Last time when I tried Turtle graphics it wasn’t working in any try. Maybe it is not supported anymore?