Guest User

Untitled

a guest
Dec 11th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. def pressed(pt, image):
  2.  
  3. width = image.getWidth()
  4. height = image.getHeight()
  5. anchor = image.getAnchor()
  6. x1 = (anchor.getX()) - (.5 * width)
  7. x2 = (anchor.getX()) + (.5 * width)
  8. y1 = (anchor.getY()) - (.5 * height)
  9. y2 = (anchor.getY()) + (.5 * height)
  10.  
  11. return(x1 <= pt.getX() <= x2 and y1 <= pt.getY() <= y2)
  12.  
  13. def timeFormat():
  14. sec = 0
  15. minute = 0
  16. hour = 0
  17. timeDisplay = "{0:02d}:{1:02d}:{2:02d}".format(hour, minute, sec)
  18. timer.setText(timeDisplay)
  19. check = win.getMouse()
  20. task = 'start'
  21. '''
  22. if pressed(check, startImage):
  23. task = 'start'
  24. '''
  25. while task == 'start':
  26. task = 'start'
  27. time.sleep(1)
  28. sec += 1
  29. if sec == 60:
  30. sec = 0
  31. minute += 1
  32. if minute == 60:
  33. sec = 0
  34. minute = 0
  35. hour += 1
  36. timeDisplay = "{0:02d}:{1:02d}:{2:02d}".format(hour, minute, sec)
  37. timer.setText(timeDisplay)
  38. check = win.checkMouse()
  39. if check != None:
  40. if pressed(check, stopImage):
  41. task = 'stop'
  42. print('stoppressed')
  43. main()
  44. '''
  45. if pressed(check, startImage):
  46. task = 'start'
  47. print('start2pressed')
  48. timeFormat()
  49. '''
  50. if pressed(check, lapImage):
  51. sec = 0
  52. minute = 0
  53. hour = 0
  54. task = 'stop'
  55. timer.setText('00:00:00')
  56. print('lappressed')
  57. timeFormat()
  58.  
  59.  
  60. def main():
  61.  
  62. check = win.checkMouse()
  63. if check!= None:
  64. while not pressed(win.checkMouse(), startImage):
  65. continue
  66.  
  67. timeFormat()
  68.  
  69. main()
Add Comment
Please, Sign In to add comment