Note that there are some explanatory texts on larger screens.

plurals
  1. POStrange turtle error when threading functions
    text
    copied!<p>When I run a script that I made, I get a very strange error. I am threading two functions, moving(), and moveWithMouse(). The relevant code is posted here:</p> <pre><code>def moving(): # Clearing the canvas and hiding the turtle for the next iteration of moving() turtle.clear() turtle.hideturtle() # Drawing all of the circles for i in range(len(xCoordinate)): turtle.penup() turtle.goto(xCoordinate[i], yCoordinate[i]) turtle.pendown() turtle.fillcolor(color[i][0], color[i][1], color[i][2]) turtle.begin_fill() turtle.circle(10) turtle.end_fill() xCoordinate[i] += speed1[i] yCoordinate[i] += speed2[i] turtle.update() turtle.ontimer(moving, 10) </code></pre> <p>Code for the next function:</p> <pre><code>def moveWithMouse(): while True: user = win32api.GetCursorPos() mousepos = [user[0]-520,-1*(user[1])+ 415] turtle.goto(mousepos) turtle.onclick(turtle.pendown()) </code></pre> <p>Then I thread both of these functions like so:</p> <pre><code> if __name__ == '__main__': Thread(target = moving).start() Thread(target = moveWithMouse).start() </code></pre> <p>And it will give me this error (It's very long, but I still think posting all of it is necessary):</p> <pre><code>Exception in thread Thread-1: Traceback (most recent call last): File "C:\Python32\lib\threading.py", line 736, in _bootstrap_inner self.run() File "C:\Python32\lib\threading.py", line 689, in run self._target(*self._args, **self._kwargs) File "C:\Python33\Circles with Collision Detection.py", line 57, in moving turtle.circle(10) File "&lt;string&gt;", line 1, in circle File "C:\Python32\lib\turtle.py", line 1991, in circle self._go(l) File "C:\Python32\lib\turtle.py", line 1605, in _go self._goto(ende) File "C:\Python32\lib\turtle.py", line 3159, in _goto screen._pointlist(self.currentLineItem), File "C:\Python32\lib\turtle.py", line 755, in _pointlist cl = self.cv.coords(item) File "&lt;string&gt;", line 1, in coords File "C:\Python32\lib\tkinter\__init__.py", line 2162, in coords self.tk.call((self._w, 'coords') + args))] File "C:\Python32\lib\tkinter\__init__.py", line 2160, in &lt;listcomp&gt; return [getdouble(x) for x in ValueError: could not convert string to float: 'coords' Exception in thread Thread-2: Traceback (most recent call last): File "C:\Python32\lib\threading.py", line 736, in _bootstrap_inner self.run() File "C:\Python32\lib\threading.py", line 689, in run self._target(*self._args, **self._kwargs) File "C:\Python33\Circles with Collision Detection.py", line 128, in moveWithMouse turtle.goto(mousepos) File "&lt;string&gt;", line 1, in goto File "C:\Python32\lib\turtle.py", line 1774, in goto self._goto(Vec2D(*x)) File "C:\Python32\lib\turtle.py", line 3159, in _goto screen._pointlist(self.currentLineItem), File "C:\Python32\lib\turtle.py", line 755, in _pointlist cl = self.cv.coords(item) File "&lt;string&gt;", line 1, in coords File "C:\Python32\lib\tkinter\__init__.py", line 2162, in coords self.tk.call((self._w, 'coords') + args))] _tkinter.TclError: ambiguous option "": must be addtag, bbox, bind, canvasx, canvasy, cget, configure, coords, create, dchars, delete, dtag, find, focus, gettags, icursor, index, insert, itemcget, itemconfigure, lower, move, postscript, raise, scale, scan, select, type, xview, or yview </code></pre> <p>It appears that it's saying there's a problem with the goto statements in both functions. Both these function work when I don't thread them, but threaded, they seem to give this very strange error. Any ideas why?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload