Max line coords canvas.create_line() can display?
jorgenhansen at hotmail.com
Thu Sep 5 03:25:20 EDT 2002
"Fredrik Lundh" <fredrik at pythonware.com> wrote in message news:<5pid9.5885$e5.1033551 at newsb.telia.net>...
> "revyakin" wrote:
> > Is there a limit of line coords (x1,y1,...xn,yn) which a Tk Canvas
> > create_line method can display? I found that I can display a line
> > consisting of 5000 x,y points, but a line of 20 000 points does not
> > get displayed.
> there shouldn't be a limit.
> can you perhaps post a (short) code snippet that illustrates
> the problem?
the small program below fails to draw the line, when it is called with
an integer larger than or equal to 16384. I only tested the script on
a Windows 98 machine with Python 2.1.3.
--- Code start ---
import random, sys
from Tkinter import *
WIDTH = 300
HEIGHT = 200
def randomcoor(n, xmin, xmax, ymin, ymax):
""" Generate n sets of random coordinates within the bounds. """
x = 
y = 
for i in range(n):
x.append(random.randrange(xmin, xmax, 1))
y.append(random.randrange(ymin, ymax, 1))
""" Draw a line for the list of coordinates. """
root = Tk()
canvas = Canvas(root, width=WIDTH, height=HEIGHT)
if __name__ == '__main__':
""" Call the script with an integer number. """
coor = randomcoor(int(sys.argv), 0, WIDTH-1, 0, HEIGHT-1)
--- code end ---
More information about the Python-list