Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | None | 0 0
  1. """
  2.  
  3. """
  4. import tkinter as tk
  5.  
  6. root = tk.Tk()
  7.  
  8. k=30
  9. W=22*k
  10. H=4*k
  11. sh0y=20
  12. sh0x=H/2
  13.  
  14. def lineAB(a,b,shx, sh0y, k):
  15.     canvas.create_line(a[0]*k+shx*4*k+sh0y,sh0x-a[1]*k,
  16.                        b[0]*k+shx*4*k+sh0y, sh0x-b[1]*k,
  17.                        width=3, capstyle=tk.ROUND)
  18. def arcAB(a,b,shx, sh0y, k):
  19.     R = ((b[0] - a[0]) / 2)*k
  20.     canvas.create_arc(a[0]*k+shx*4*k+sh0y, sh0x-R,
  21.                       b[0]*k+shx*4*k+sh0y, sh0x+R,
  22.                       start=180, extent=-180, style=tk.ARC,
  23.                        width=3)
  24.  
  25. canvas = tk.Canvas(root, width=W, height=H,bg='white')
  26. canvas.pack()
  27.  
  28. # Horizontal line
  29. i=1
  30. while sh0x+i*k < H:
  31.     canvas.create_line(0,sh0x+i*k, W, sh0x+i*k, fill='cyan')
  32.     canvas.create_line(0,sh0x-i*k, W, sh0x-i*k, fill='cyan')
  33.     i += 1
  34.  
  35. # Vertical line
  36. i=1
  37. while sh0y+i*k < W:
  38.     canvas.create_line(sh0y+i*k,0, sh0y+i*k, W, fill='cyan')
  39.     i += 1
  40.  
  41. canvas.create_line(0,sh0x,  W, sh0x, fill='gray', arrow=tk.LAST)#0x
  42. canvas.create_line(sh0y,H,  sh0y, 0, fill='gray', arrow=tk.LAST)#0y
  43.  
  44.  
  45.  
  46.  
  47. xy = [[0,-1], [1,0], [3,0], [3,-1], [4,-1]]
  48. for i in range(5):
  49.     lineAB(xy[0], xy[1], i, sh0y, k)
  50.     arcAB(xy[1], xy[2], i, sh0y, k)
  51.     lineAB(xy[2], xy[3], i, sh0y, k)
  52.     lineAB(xy[3], xy[4], i, sh0y, k)
  53.  
  54.  
  55.  
  56.  
  57. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement