Oct 31st, 2020
1,208
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
2.
3. from Tkinter import *
4. import random
5. import math
6. import time
7.
8. WW = 1200
9. HH = 680
10. root = Tk()
11. root.geometry(str(WW)+"x"+str(HH)+"+5+5")
12. canvas = Canvas(root, width=WW, height=HH)
13. canvas.pack()
14.
16. vectors = 1000
17. midx,midy = 600,360
18. TWO_PI = math.pi*2
19.
21.     d = {}
22.     d2bn = 0
23.     if angles:
24.         d2bn = 360.0/angles
25.     for angle in range(angles):
26.         a = angle
27.         a = a*d2bn
30.         d[angle] = x,y
31.     return d
32.
33. class Slider:
34.     def __init__(self, master=None, label='', value=0.0, min=0.0, max=100):
35.         slist.append(0)
36.         slist[-1] = DoubleVar()
37.         s = Scale(  master,
38.                     label=label,
39.                     variable=slist[-1],
40.                     from_=min*1.0,
41.                     to=max*1.0,
42.                     orient=HORIZONTAL,
43.                     length=max)
44.         slist[-1].set(value)
45.         s.place(x=(len(slist)-1)*120,y=0)
46.
47. slist = []
48. Slider(canvas, label='vector points', max=1180, min=300)
49.
50. timer = 0
51. p = p2 = 0
52. while 1:
53.     vectors = int(slist[0].get())
54.     if p <> vectors:
55.         timer = time.time()+0.3
56.         p = vectors
57.     if p2 <> vectors and timer < time.time():
59.         canvas.delete('all')
60.         points = []
61.         for i in range(vectors):
62.             x,y = PERIM[i]