Tkinter.create_dot()

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Tue Jul 16 11:16:52 EDT 2002


On Tuesday 16 Jul 2002 2:39 pm, Martin Franklin wrote:
> 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.
>
>

Following on if you are doing 'thousands' of dots you should check out tk3000

http://www.pythonware.com/products/tkinter/tkinter3000.htm

Cheers
Martin











More information about the Python-list mailing list