Excuse the multiple posts yesterday. Gmail was playing up,
saying it coulnd't send, when in fact it had.

Mick

2009/5/14 Michael O'Donnell <michael.odonn...@uam.es>:
> See below code which moves 10,000 small disks (6x6 pixels)
> around a canvas 1000x1000 pixels, without regard to stacking order
> (no z axis for disk positions), and moving disks randomly +-1 in
> the x and y axis each iteration:
>
> Takes about 1 second per iteration on my old slow windoze box:
>
> from Tkinter import *
> from random import randint
>
> class MyCanv(Canvas):
>
>    def setup(self, diskCount):
>        self.wgts=[]
>        for i in range(diskCount):
>            x=randint(0,1000)
>            y=randint(0,1000)
>            wid=canv.create_oval(x, y, x+6, y+6, fill="blue")
>            self.wgts.append((wid, x, y))
>
>        while True:
>            self.update1()
>
>    def update1(self):
>        newItems=[]
>        for item,x,y in self.wgts:
>            xdiff=randint(-1,1)
>            ydiff=randint(-1,1)
>            newx=x+xdiff
>            newy=y+ydiff
>            if newx<0 or newx>1000:
>                xdiff=0
>                newx=x
>            if newy<0 or newy>1000:
>                ydiff=0
>                newy=y
>            self.move(item, xdiff, ydiff)
>            newItems.append((item,newx, newy))
>        self.wgts=newItems
>        self.update()
>
> main=Tk()
> canv=MyCanv(main, bg="white", height=1000, width=1000)
> Button(main, text="Start", command=lambda c=canv: c.setup(10000)).pack()
> canv.pack(side=TOP)
> main.mainloop()
>
>
>
> 2009/5/14 Protosssword <xs...@hotmail.com>:
>> Dear Colleagues,
>>
>> I am considering using python to write a simulation program to display the
>> motions of about 10,000 2d disks. The program doesn't need to calculate the
>> positions of disks. It just reads the result file and displays disks on the
>> screen. I wonder whether Tkinter has this ability for rendering so many
>> disks in time.
>>
>> Thanks!
>>
>>
>> Shengxu Xia
>>
>> ________________________________
>> 使用新一代 Windows Live Messenger 轻松交流和共享! 立刻下载!
>> _______________________________________________
>> Tkinter-discuss mailing list
>> Tkinter-discuss@python.org
>> http://mail.python.org/mailman/listinfo/tkinter-discuss
>>
>>
>
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to