Updating a line in a canvas.

Fredrik Lundh fredrik at pythonware.com
Thu Apr 26 18:40:45 EDT 2001


Hans Kristian Ruud wrote:
> If I subsequently try to modify the curve by this statement:
>
> canvas.coords(obj, coords)
>
> where coords is the list of new coordinates, I get this error message:
>
>  File "C:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1205, in
> coords
>     self.tk.splitlist(
> TclError: too few coordinates for line: must have at least 4
>
> Is there any way to get around this problem

for some reason, "coords" doesn't "flatten" its arguments.
in Python 2.0, you can use:

    canvas.coords(obj, *coords)

in earlier versions, you have to do something like:

    apply(canvas.coords, (obj,) + tuple(coords))

Cheers /F





More information about the Python-list mailing list