Updating a line in a canvas.

Hans Kristian Ruud hans at inenco.no
Thu Apr 26 16:39:57 EDT 2001


A curve may be drawn in a canvas by creating a line object

        obj = canvas.create_line(coords,fill='red', smooth=1, width=wid)

where coords is a list of x, y-coordinates for the curve.

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, or do I have to use a
specific
set of new coordinates, something like the following.

canvas.coords( obj, x1, y1, x2, y2,..., xn, yn)?

It would be very convenient to be able to draw curves with an arbitrary
number of coordinates.


Thanks in advance - på forhånd takk

- hans kristian -





More information about the Python-list mailing list