Howdy, Stranger!

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

Supported by

Using forms in Psychopy backend

Hello everyone,
I have trying to design my experiment in open sesame whereby I request the subject to enter personnel info before starting the trial ( name, age, sex etc), followed by gap overlap task so it needs to be fairly accurate so I am using psychopy backend. But while using this backend if I try to add the consent form as well as a custom form, the experiment hangs and I have to quit the experiment. Also, in general I tried running the in-built consent form in expyriment backend but I was facing the same issue. It is only working in legacy backend.

I hope my problem is clear. Can anybody suggest a possible workaround?
Is it possible to draw same custom form in psychopy through inline script instead of using the widgets?

Thank you in advance

Comments

  • Hi,

    I'm not sure what causes your problem, but it is certainly possible to create a form by means of an inline_script rather than the widgets. This will require a bit of coding however. You'll have to manually program a text bar in which people can input text, and this text also needs to be made visible as the participant types.
    I do have some code that takes care of this here:

        answered = False
        letters = 0
        resp = ''
    
        while answered == False:
            key, timestamp = my_keyboard.get_key(timeout = 1)
            if key == 'backspace':
                if len(resp)>0:
                    startpoint -= exp.input_canvas.text_size('w')[0]
                    exp.input_canvas.rect(x=startpoint-exp.canvas.text_size('x')[0]*0.5,y=exp.canvas.ycenter()+30,\
                    w=exp.canvas.text_size('w')[0], h = 30, fill=True)
                    exp.input_canvas.show()
                    resp = resp[0:-1]
            elif key == 'return':
                answered = True
            elif key != None and key != 'left' and key != 'right' and len(resp)<6:
                exp.input_canvas.rect(x=startpoint,y=exp.canvas.ycenter()+30,\
                w=exp.canvas.text_size('w')[0], h = 30, fill=True)
                exp.input_canvas.text(key,x=startpoint,y=exp.canvas.ycenter()+45, color='white')
                startpoint += exp.input_canvas.text_size('w')[0]
                exp.input_canvas.show()
                resp += key
    

    You just have to define the variable startpoint, which represents the x-coordinate at which the first letter needs to appear. All the other info and instructions you want to have on your form can be added with the canvas.text() function (see also http://osdoc.cogsci.nl/3.1/manual/python/canvas/#function-canvas46text40text-centertrue-xnone-ynone-max95widthnone-4242style95args41).

    Cheers,

    Josh

  • Thanks Josh,
    I tried running the above code in psychopy backend but when I run the code all I see is a blank screen. I think I am able to enter the text input but it is not visible. Am I missing something?

    For reference, I am posting the inline script I am using:

    from openexp.keyboard import keyboard
    from openexp.canvas import canvas
    my_keyboard = keyboard(exp, timeout=None)
    input_canvas = canvas(exp)
    startpoint = input_canvas.xcenter()
    answered = False
    letters = 0
    resp = ''

    while answered == False:
    key, timestamp = my_keyboard.get_key()
    if key == 'backspace':
    if len(resp)>0:
    startpoint -= input_canvas.text_size('w')[0]
    input_canvas.rect(x=startpoint-input_canvas.text_size('x')[0]*0.5,y=input_canvas.ycenter()+30,\
    w=input_canvas.text_size('w')[0], h = 30, fill=True)
    input_canvas.show()
    resp = resp[0:-1]
    elif key == 'return':
    answered = True
    elif key != None and key != 'left' and key != 'right' and len(resp)<6:
    input_canvas.rect(x=startpoint,y=input_canvas.ycenter()+30,\
    w=input_canvas.text_size('w')[0], h = 30, fill=False)
    input_canvas.text(key,center=True, x=startpoint,y=input_canvas.ycenter()+45, color='white')
    startpoint += input_canvas.text_size('w')[0]
    input_canvas.show()
    resp += key

  • I was able to figure out that I was defining the coordinates of rect and text in a format supported by earlier version of open sesame by taking the top left coordinate, because of which they were being drawn outside of the screen. By changing it, relative to the center coordinates I was able to get the result.

    Thanks for the help!

  • No problem!

    Josh

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