Problem executing an event in a created extension
I have created an extension as described in the official documentation but I can't figure out how to execute an event inside the extension.
I have created an extension as described in the official documentation but I can't figure out how to execute an event inside the extension.
Comments
Hi Chris,
You can fire events from within an extension like so:
self.extension_manager.fire('some_event', argument1=value1, argument2=value2)This will then result in the following event-handler functions being called:
The event name can be anything, so extensions can also make up their own events if they need to, for example to communicate with each other. If no-one is listening to the event, it will simply be ignored. And the arguments have to be passed as keywords, i.e. not by order. I hope this clears things up! (And thanks for pointing out that this information is missing in the docs.)
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hello Sebastian and thank you for your quick response,
I am a bit confused with the answer you gave me. So I have added the
example extension given at the documentation to my OpenSesame extensions directory and it recognizes it.
How can I now make that extension start when I run an experiment ?
I understand that some extensions start when the OpenSesame software starts. But I would like the experiment to trigger some of the extension's events while running and not just when it starts.
Thank you,
Chris
Hi Chris,
Most likely an error occurs while loading the extension. To develop an extension, it's useful to enable a console with an inprocess kernel (Menu → Tools → Preferences), because this allows you to access the OpenSesame internals. (Normally, the console will have its own kernel.) This requires OpenSesame 3.3. Once you've enabled that, and restarted OpenSesame, the console labeled 'Python (1)' will have an
opensesameobject in it, which corresponds to the application itself. And with this you can test whether your extension loads, like so (but of course change the name of the extension fromafter_experimentto your extension):You'll probably see some errors when you try this, and then you can start debugging from there!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Thank you Sebastian for the quick reply once again.
I managed to make the extension load when the OpenSesame software runs just by changing the
disabled: truesetting from the .yaml file.I also tried the commands you suggested and I get this error:
Moreover, the problem I have and I want to figure out is, how to execute a specific event of an extension while running a certain experiment ? For example should that be coded in an
inline_script? Can also be executed for example in asequence? And if yes, how ?Thank you very much for your time and help,
Christos
I also tried the commands you suggested and I get this error:
You have to enable the inprocess console, as I explained in my previous post.
Moreover, the problem I have and I want to figure out is, how to execute a specific event of an extension while running a certain experiment ? For example should that be coded in an
inline_script? Can also be executed for example in asequence? And if yes, how ?There's a distinction between plugins and extensions.
From your question, it seems like you actually want to create a plugin. Is that correct? If so, then the next step would be to define exactly what you want to do (which is not clear from your question) and only then how to do it!
Check out SigmundAI.eu for our OpenSesame AI assistant!