May-29-2019, 06:01 AM
(This post was last modified: May-29-2019, 06:01 AM by skyerosebud.)
I am creating a simple reaction time task for a piece of psychology research.
I created the program in Pygame and it worked well but Pygame has very poor ability to create text GUI so I have attempted shift to tkinter and I am attempting to rebuild the test.
Essentially the letter 'A' is presented on the screen and the time taken to press key 'A' is measured.
whiteA=canvas.create_text(200,550, text="A"...)
startTime=time.perf_counter()
root.bind("<Key>", lambda event: calc_react_time(event, startTime, whiteA))
Problem is any key press 'A' prior to presentation of the on-screen stimulus 'A' triggers the keybind immediately, giving a close-to-zero reaction time.
Pygame has event clearing syntax that prevents the key already entered in the buffer from triggering the keybind (?clears the buffer)...
pygame.event.clear()
display_surface.blit(textA_white, textRectA)
pygame.display.update()
I have been unable to find anything similar in Tkinter. Am I missing anything? How to clear the buffer immediately prior to presenting the stimulus as in Pygame?
Also pygame has a wait command (waiting for key entry before continuing)
event = pygame.event.wait()
Does Tkinter have a similar function?
Many thanks, Skyerosebud
I created the program in Pygame and it worked well but Pygame has very poor ability to create text GUI so I have attempted shift to tkinter and I am attempting to rebuild the test.
Essentially the letter 'A' is presented on the screen and the time taken to press key 'A' is measured.
whiteA=canvas.create_text(200,550, text="A"...)
startTime=time.perf_counter()
root.bind("<Key>", lambda event: calc_react_time(event, startTime, whiteA))
Problem is any key press 'A' prior to presentation of the on-screen stimulus 'A' triggers the keybind immediately, giving a close-to-zero reaction time.
Pygame has event clearing syntax that prevents the key already entered in the buffer from triggering the keybind (?clears the buffer)...
pygame.event.clear()
display_surface.blit(textA_white, textRectA)
pygame.display.update()
I have been unable to find anything similar in Tkinter. Am I missing anything? How to clear the buffer immediately prior to presenting the stimulus as in Pygame?
Also pygame has a wait command (waiting for key entry before continuing)
event = pygame.event.wait()
Does Tkinter have a similar function?
Many thanks, Skyerosebud