Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def pressed(pt, image):
- width = image.getWidth()
- height = image.getHeight()
- anchor = image.getAnchor()
- x1 = (anchor.getX()) - (.5 * width)
- x2 = (anchor.getX()) + (.5 * width)
- y1 = (anchor.getY()) - (.5 * height)
- y2 = (anchor.getY()) + (.5 * height)
- return(x1 <= pt.getX() <= x2 and y1 <= pt.getY() <= y2)
- def timeFormat():
- sec = 0
- minute = 0
- hour = 0
- timeDisplay = "{0:02d}:{1:02d}:{2:02d}".format(hour, minute, sec)
- timer.setText(timeDisplay)
- check = win.getMouse()
- task = 'start'
- '''
- if pressed(check, startImage):
- task = 'start'
- '''
- while task == 'start':
- task = 'start'
- time.sleep(1)
- sec += 1
- if sec == 60:
- sec = 0
- minute += 1
- if minute == 60:
- sec = 0
- minute = 0
- hour += 1
- timeDisplay = "{0:02d}:{1:02d}:{2:02d}".format(hour, minute, sec)
- timer.setText(timeDisplay)
- check = win.checkMouse()
- if check != None:
- if pressed(check, stopImage):
- task = 'stop'
- print('stoppressed')
- main()
- '''
- if pressed(check, startImage):
- task = 'start'
- print('start2pressed')
- timeFormat()
- '''
- if pressed(check, lapImage):
- sec = 0
- minute = 0
- hour = 0
- task = 'stop'
- timer.setText('00:00:00')
- print('lappressed')
- timeFormat()
- def main():
- check = win.checkMouse()
- if check!= None:
- while not pressed(win.checkMouse(), startImage):
- continue
- timeFormat()
- main()
Add Comment
Please, Sign In to add comment