user interface - How do I create a reaction timer in python as GUI? -


i have problem making reaction timer. want button in program gives me time took press button time timer started.

let's open program want button if click it, print time took me press after timer started. after clicked button want timer reset , again when click button print time took me click button again.

i have following code:

from tkinter import* import time import os import datetime  s=0 m=0 h=0  def myclickme1():     myv=float(myvaluta.get())     valuta=myv      label3["text"]=valuta*b     label4["text"]=valuta*c     label5["text"]=valuta*d     label6["text"]=valuta*e     return  window=tk() myvaluta=stringvar()  window.geometry("700x800") window.title("reaktionshastighehs test")  button1=button(window, text="klik her!", command=myclickme1)  button1.place(x=330, y=460) 

just clear: have mate button in gui want make work when click it, print time took me press after program started. , if press button again tell me time took me press after had pressed first time.

you can use time library.

import time start = time.clock() # when program starts finish = time.clock() # after user clicks button  elapsed_time = finish - start # 'reaction time' 

just call time.clock() whenever need know when user did (clicked first button or second button). can use subtraction on these times. answer in seconds.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -