VU-Cog-Sci / exptools2

Version 2 of exptools (by KnapenLab)
11 stars 9 forks source link

Hard to overload get_events() #19

Closed Gilles86 closed 5 years ago

Gilles86 commented 5 years ago

When developing an experiment, I noticed that I can't overload the get_events()-method of the Trial-class, without repeating the logging part etc entirely: If you use super().get_events(), that method flushes the event buffer using psychopy.events.getKeys(), which means I can't access the events/keys that were pressed.

I propose that we let Trial.get_events() also return events, so that overloaded methods can act on it, without repeating/rewriting the logging part. So you could do:

My Trial(...):
    def get_events():
        events = super().get_events()
        if 'y' in events:
            print("yo")

And still everything get logged.

Any ideas?

lukassnoek commented 5 years ago

Sounds like a good plan. So events, here, is a list of keys pressed relative to the previous flip (i.e., the output of getKeys())?

Gilles86 commented 5 years ago

Yup. I made a pull request, #20...

lukassnoek commented 5 years ago

Merged #20.