Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

how to use variables collected by a plugin?

edited June 2022 in OpenSesame

Dear opensesame users,


I'm a newbee in the opensesame world. I have a project to complet to I need to develop some plugins to achieve this. Since I have no experience with opensesame I tried first to write a minimal plugin. Here are the info.yaml and to *.py files:


info.yaml

author: author
category: plugin essai
description: un plugin d'essai
controls:
-
   label: essai
   name: line_edit_essai
   type: line_edit
   var: essai


*.py

from libopensesame.py3compat import *
from libopensesame.oslogging import oslogger
from libopensesame.item import item
from libqtopensesame.items.qtautoplugin import qtautoplugin

class plugin_essai(item):
   def reset(self):
       self.var.essai = u'un texte par défaut'
       oslogger.debug('plugin_essai has been initialized')

   def prepare(self):
       item.prepare(self)

   def run(self):
       self.set_item_onset()



class qtplugin_essai(plugin_essai, qtautoplugin):
   def __init__(self, name, experiment, script = None):
       plugin_essai.__init__(self, name, experiment, script)
       qtautoplugin.__init__(self, __file__)

Very simple as you can see. Here is my question: A essai variable is declared in the yaml file to capture the line_edit data and is passed to var in the class plugin_essai. Up to this, it seems in line with what I understand of opensesame. However, this var.essai variable is not registered in the var inspector and, accordingly, a script that would try to use it crash with the error message No essai variable exists. Could you help me to figure how to use informations captured in a plugin?


Thanks so much for your help.

Best regards,

Hugues

Comments

  • Hi @HuguesJ ,

    Each item (or plugin) has its own var object, which is used to store item-specific information, but is not (easily) accessible from outside the item. The var object that you see in an inline_script item is actually part of the experiment object. Practically speaking, this means that if you want your item to expose experimental variables you would do it like this:

    self.experiment.var.my_item_variable = 'some value'
    

    Hope this helps!

    — Sebastiaan

  • Hi sebastiaan,


    Thanks so much for this kind and nice answer. I did not figure that the var object was part of experiment object. I thought it was an independant opensesame object overseeing all var variables and making them public for the whole experiment. Your explanation helps a lot.

    I figured an other way to manipulate the variables/attributes of a plugin. Actually, the plugin is an item and it can be manipulate like other items of opensesame using the 'items' command. Thus it is possible to reach attributes and likely methods using this synthax:

    items['plugin name'].var.'variable_name'

    This is not very intuitive when you are coding in pure python, but fairly logical considering opensesame philosophy. Besides this, it is not that bad at the end since it recalls in the code where the variable is comming from.

    Anyway, thanks again for your help and I hope my question and answers will help other new opensesame users to make their way in this software philosophy.

    Best regards,

    Hugues

  • Thanks so much for this kind and nice answer. I did not figure that the var object was part of experiment object. I thought it was an independant opensesame object overseeing all var variables and making them public for the whole experiment. Your explanation helps a lot.

    I figured an other way to manipulate the variables/attributes of a plugin. Actually, the plugin is an item and it can be manipulate like other items of opensesame using the 'items' command. Thus it is possible to reach attributes and likely methods using this synthax:

    items['plugin name'].var.'variable_name'

    This is not very intuitive when you are coding in pure python, but fairly logical considering opensesame philosophy. Besides this, it is not that bad at the end since it recalls in the code where the variable is comming from.

    Anyway, thanks again for your help and I hope my question and answers will help other new opensesame users to make their way in this software philosophy.

    Best regards,

    Hugues

     

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games