2

Python で作成したこの簡単なプログラムがあり2.7.5ます。基本的には画面にランダムなものをたくさん描いているだけですが、キャンバスを閉じると奇妙なエラーが発生します。

import turtle
import random
import time

turtle.hideturtle()

class Mus:

    def __init__(self):
        turtle.setx(random.randint(1,100))
        turtle.sety(random.randint(1,100))
        turtle.circle(random.randint(1,100))

while True:
    Mus()

turtle.exitonclick()

プログラムを閉じると、次のエラーが表示されます。

Traceback (most recent call last):
  File "/Users/jurehotujec/Desktop/running.py", line 15, in <module>
    Mus()
  File "/Users/jurehotujec/Desktop/running.py", line 12, in __init__
    turtle.circle(random.randint(1,100))
  File "<string>", line 1, in circle
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/turtle.py", line 1908, in circle
    self._rotate(w)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/turtle.py", line 3110, in _rotate
    self._update()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/turtle.py", line 2564, in _update
    self._update_data()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/turtle.py", line 2555, in _update_data
    self._pencolor, self._pensize)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/turtle.py", line 569, in _drawline
    self.cv.coords(lineitem, *cl)
  File "<string>", line 1, in coords
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 2240, in coords
    self.tk.call((self._w, 'coords') + args)))
TclError: invalid command name ".4335016920"

私は何を間違っていますか?私はPythonが初めてなので、助けていただければ幸いです:)

ありがとう

4

2 に答える 2