Tkinter.create_dot()

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Tue Jul 16 10:39:00 EDT 2002


On Monday 15 Jul 2002 10:55 pm, Justin Shaw wrote:
> I'm using a Tkinter.Canvas to create a picture of thousands of dots.  I am
> using
> Tkinter.Canvas.create_line()
> with a line of length one for each dot which really seems to bog down the
> computer.
>
> Is there a better way?


Not really but you could use a PhotoImage like so:-


from Tkinter import *
root=Tk()
canvas=Canvas(root)
canvas.pack()

pxmap=PhotoImage(width=10, height=10)
for x in range(10):
    for y in range(10):
        pxmap.put('red', (x, y))

canvas.create_image(10, 10, image=pxmap)
root.mainloop()



This will create a red square at 10, 10 in the canvas.


Cheers
Martin







More information about the Python-list mailing list