1 # Brownian motion -- an example of a multi-threaded Tkinter program.
17 stop
= 0 # Set when main loop exits
21 x
= random
.gauss(WIDTH
/2.0, SIGMA
)
22 y
= random
.gauss(HEIGHT
/2.0, SIGMA
)
23 p
= canvas
.create_oval(x
-r
, y
-r
, x
+r
, y
+r
, fill
=FILL
)
25 dx
= random
.gauss(0, BUZZ
)
26 dy
= random
.gauss(0, BUZZ
)
27 dt
= random
.expovariate(LAMBDA
)
29 canvas
.move(p
, dx
, dy
)
37 canvas
= Canvas(root
, width
=WIDTH
, height
=HEIGHT
)
38 canvas
.pack(fill
='both', expand
=1)
43 t
= threading
.Thread(target
=particle
, args
=(canvas
,))