Kyle Campbell
Kyle Campbell

Reputation: 37

Turtle will not draw in PyCharm

So I am having an issue with turtle not drawing images when executing in pycharm.

The window comes up and stays open, but the cursor just sits there. It is not executing the instructions to draw the image as needed. This is in 2 separate files, main.py and turtle.cfg file.

main.py has this code in it

import turtle

t = turtle.Turtle()
t.width(2)
t.pencolor("red")


def square(t, length):
    for count in range(4):
        t.forward(length)
        t.left(90)



square()
turtle.done()

and turtle.cfg has this in it

width = 300
height = 200
using_IDLE = True
colormode = 255

That's it. It should be super simple, and yet for some reason when I open it, the cursor just sits in the center of the screen and goes nowhere. For transparency, this is copied directly from my text book as a learning example, so I would think that it should work.

Upvotes: 0

Views: 319

Answers (1)

dzshn
dzshn

Reputation: 56

the function square was never called, so it never runs, you can try placing square(t, 40) (or another number) right before turtle.done() like so:

import turtle

t = turtle.Turtle()
t.width(2)
t.pencolor("red")


def square(t, length):
    for count in range(4):
        t.forward(length)
        t.left(90)

square(t, 40)
turtle.done()

Upvotes: 2

Related Questions