from abc import ABC, abstractmethod
from psychopy.visual import Window
from psychopy import logging
logging.console.setLevel(logging.ERROR)
[docs]
class BaseGUI(ABC):
def _create_experiment_window(self) -> Window:
"""
Create and return the PsychoPy experiment window.
Returns
-------
psychopy.visual.Window
The experiment display window.
"""
return Window(
fullscr=self.fscreen, screen=self.screen, size=(1920,1080),
winType='pyglet', allowGUI=True, allowStencil=False,
color=[0,0,0], colorSpace='rgb', blendMode='avg',
useFBO=True, units='norm'
)
def _draw_stims(self, stims, flip=True) -> None:
"""
Draw and optionally flip a list of stimuli.
Parameters
----------
stims : list
List of PsychoPy stimulus objects to draw.
flip : bool
Whether to flip the window after drawing (default: True).
"""
for stim in stims:
stim.draw()
if flip:
self.ewin.flip()
[docs]
@abstractmethod
def draw_resting_screen(self) -> None:
"""Draw the default resting screen (e.g., crosshair + text)."""
pass
[docs]
@abstractmethod
def poll_trigger(self) -> None:
"""Poll for triggers or escape key (for latency testing)."""
pass
[docs]
@abstractmethod
def close_psychopy_window(self) -> None:
"""Close the PsychoPy window."""
pass
[docs]
@abstractmethod
def save_trigger(self) -> None:
"""Save collected trigger timings to disk."""
pass