| Reference | Downloads | Github

Subclassing PsychoPy visual stimuli not working

I’ve just installed PsychoPy 3 using anaconda and following instructions
System details:
python version 3.5.6
psychopy version 1.90.2
MacBook Pro 2015, macOS High Sierra

I am trying to subclass ElementArrayStim. Here is dummy code:
class MotionStim(ElementArrayStim):
And I get the error:
TypeError: ‘str’ object does not support item assignment

The error has something to do with file and the line:
scope[name] = self

Finally, this is not specific for ElementArrayStim. I tried the same code with ShapeStim, with the same error.

I have tried the whole thing on Python 2.7, PsychoPy 1.90.2. But using this setup I get:
TypeError: Error when calling the metaclass bases
metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

Any suggestions how to manage subclassing?

Cheers, Dragan

It should work if you import it directly:

from psychopy.visual.elementarray import ElementArrayStim

class MotionStim(ElementArrayStim):

That worked quite nicely. Thanks for the tip!