I'm not a programmer. I am doing a project for Biology where I will be conducting an experiment on reaction times. Briefly, the subject should click anywhere on the screen as soon as a dot or circle (some graphic) appears on the screen.


  1. Program must start at a set clock time (e.g. 16:03:00) which will be typed in every time
  2. Timer must start when program starts (t=0)
  3. Graphics will appear at the same point (coordinates) according to pre-determined times relative to start (e.g., 1.5s, 2s, 3.5s, ...) for 2 minutes.
  4. Each time the subject presses the mouse, the time relative to the timer must be recorded.

Afterward, I will just tabulate the data on a spreadsheet and calculate the time differences between the time the graphic appears and the time the subject presses the mouse.

I have very limited knowledge of Python. I've never done anything with graphics on Python. This is the best set up I can think of for my needs.

I did some research and this is what I've found so far:

  • For the graphics: Pyglet has a built in scheduling function (pyglet.clock.schedule_interval)
  • I can use either time.time or time.clock for measuring reaction times. I am kind of confused over which one to use. It seems there is some subtle difference that I'm not understanding.

Please also not that the program may be run on a windows 7 PC or a MacBook.

I don't need a complete answer. Just some suggestions and tips to point me in the right direction for further research. Thanks.

(P.S. For more info on experiment setup, please check my other question http://www.daniweb.com/hardware-and-software/threads/439985/connecting-one-mouse-to-two-laptops#)

Edited by jey1234

4 Years
Discussion Span
Last Post by Tcll

I don't think there are many people here who use Pyglet. Many use Tkinter or Wx with a few Pyside/QT people thrown in. The Pyglet main page says that pyglet-users is the main forum, and should know more about it than we do.


This article has been dead for over six months

<<< so what, I have a reason for necro-posting in that the info provided here is not very good.
(threads don't disappear or I wouldn't have stumbled upon this one just now)

Pyglet is like PyQt4 when it comes to performance, it just plain sucks, and Pyglet also lacks in support when you're looking for faster methods, such as 16bit floats for vert-coords.

I would have to recommend PyOpenGL using PyGLFW for a window manager.
(Pygame sucks, SDL is very destructive when it comes to the GL context on window resize)

as for timeing... time.time sucks and is very inaccurate when it comes to being exact.

here's what I'd used before settling on V-sync (GPU-sided timing) for shutter rendering a 3D scene (3D viewing how 3DTVs do it).
import time as _time, platform as _platform

time = _time.clock if _platform.system() == 'Windows' else _time.time
currentTime = previousTime = time()
endtime =  1./mode.refresh_rate

while not win.should_close:

    eye = not eye



    previousTime = currentTime; currentTime = time()
    endtime2 = endtime+( (endtime-(currentTime-previousTime)) *.5 )
    if endtime2-(time()-currentTime) > 0:
        while True:
            if endtime2 <= (time()-currentTime): break

it's still not 100% accurate, but it's much more accurate than the latter.

personally though, GPU-sided timing is much more accurate than that, so if you could just do 1.0/frame-rate with the swap interval (V-sync) set, you'll be able to track ticks even better :)
(it's still not 100% accurate, but it's the most accurate thing I've used yet)

when it comes to python, I'm all about performance since I work with 3D models (almost to the point of developing games). ;)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.