0

I have looked at similar questions but I still can't seem to solve this problem. I am trying to use Python Turtle in Pycharm and it simply won't work. I get the message "Not responding".

It should also be noted that this is an issue solely with Pycharm. I have tried running this code in vs code and in the command prompt and it works on both of them. However, I really like using Pycharm and would like to also use it for this project.

This is my code:

import turtle

WIDTH, HEIGHT = 500, 500

screen = turtle.Screen()
screen.setup(WIDTH, HEIGHT)
screen.title("Turtle Racing")

def get_number_of_turtles():
    num_turtles = 0
    while True:
        num_turtles = input("Enter the number of racers (2-10): ")
        if num_turtles.isdigit():
            num_turtles = int(num_turtles)
        else:
            print("Invalid input.")
            continue

        if 2 <= num_turtles <= 10:
            return num_turtles
        else:
            print("Number not in range 2-10.")

get_number_of_turtles()

Does anyone know how to solve this issue?

António Rebelo
  • 186
  • 1
  • 13
  • maybe because you have `input` in your code which doesn't let that window update? it blocks until you input something, which also means that this is not a Pycharm only issue.... or does `turtle` update in a separate thread or process? – Matiiss Mar 19 '22 at 08:56
  • @Matiiss I don't think so because this runs in vs code as well as the command prompt – António Rebelo Mar 19 '22 at 08:57
  • I see, still the issue is that you have `input` there, which blocks until you input something, also VSC uses the terminal as well so running it in VSC or cmd is the same, Pycharm is an IDE (but you can run the code from terminal there too) – Matiiss Mar 19 '22 at 08:58
  • I would suggest that you ask for `input` before creating the `turtle` screen – Matiiss Mar 19 '22 at 09:02

0 Answers0