Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. import Tkinter
  2. import threading
  3. import Queue
  4.  
  5. top = Tkinter.Tk()
  6. coordQueue = Queue.Queue()
  7.  
  8.  
  9. xMax = int(0)
  10. xMin = int(0)
  11. yMax = int(0)
  12. yMin = int(0)
  13. xStart = int(0)
  14. yStart = int(0)
  15. xSize = int(0)
  16. ySize = int(0)
  17.  
  18. xPrev = int(0)
  19. yPrev = int(0)
  20.  
  21. first = True
  22.  
  23. point = 100, 400
  24. coordQueue.put(point)
  25. #coordQueue.get(1)
  26.  
  27. def addline(point):
  28. x = point[0]
  29. y = point[1]
  30.  
  31. global marg, yMax, xMax, yMin, xMin, xStart, yStart, xSize, ySize
  32.  
  33. marg = int(10)
  34.  
  35. if y > yMax:
  36. yMax = y
  37. if y < yMin:
  38. yMin = y
  39. if x > xMax:
  40. xMax = x
  41. if x < xMin:
  42. xMin = x
  43.  
  44. xStart = xMin - xMin*(marg/100)
  45. yStart = yMin - yMin*(marg/100)
  46. xSize = (xMax + xMax*(marg/100)) - xStart
  47. ySize = (yMax + yMax*(marg/100)) - yStart
  48.  
  49. line = xPrev, yPrev, x, y
  50.  
  51. C = Tkinter.Canvas(top, bg="white", height=xSize, width=ySize)
  52. C.create_line(line)
  53. C.pack()
  54.  
  55. top.mainloop()
  56.  
  57. def checkQueue():
  58. print "jaman checkQueue"
  59. if coordQueue.not_empty:
  60. for i in list(coordQueue.queue):
  61. point = coordQueue.get(i)
  62. addline(point)
  63. break
  64.  
  65. def myLineThread():
  66. print "Jaman myLineThread"
  67. if checkQueue():
  68. try:
  69. threading.Timer(1.0, checkQueue).start()
  70. except Exception, st:
  71. print "threadingen is knas: %s" % st
  72. try:
  73. print "Sista try"
  74. myLineThread()
  75. except Exception, e:
  76. print "Addline fungerar inte: %s" % e
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement