Howdy, Stranger!

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

Supported by

[solved] How to have text input with an image (and updating)

edited October 2014 in OpenSesame

Hello,

This may be redundant, but the last thread I could find on this question was a few years old. So, I'll ask it again for the newer version of opensesame.

I need my participants to be able to view a picture on sketchpad and then enter a multi-character keyboard response. Right now I have them viewing the sketchpad, doing a keypress to advance, and then using text_input to enter their response.

Alternatively, a more complicated arrangement that I would like is for participants to be able to order a sequence and receive updates regarding the order (e.g., water jug problem or tower of hanoi problem) and be allowed to advance once they have solved the multi step problem. How might that be possible?

Thank you for your time.
Jared

Comments

  • edited October 2014

    Hi Jared, and welcome to the forum!

    In general, both of your questions can be addressed by inline scripting. However, the first one (typing and concurrently displaying an image) is considerably easier to do that the second one (touch/click interaction with an animated display). The code for the first I give you below, the code for the second is something you could try to go for yourself after familiarizing yourself with Python (see here for some tips).

    Display image and typed text

    Place this code in the Run phase of an inline_script item. Based on my code in this thread. This assumes you have defined a variable imgname in the loop item through which you run this!

    from openexp.canvas import canvas
    from openexp.keyboard import keyboard
    
    # get the image name and path
    fname = exp.get_file(self.get('imgname'))
    
    # vertical coordinate of image and text
    imgy = int(self.get('height') * 0.3)
    txty = int(self.get('height') * 0.8)
    
    # allowed characters
    allowed = 'abcdefghijklmnopqrstuvwxyz.,'
    
    # create objects
    my_kb = keyboard(exp)
    my_canvas = canvas(exp)
    
    # draw the first canvas
    my_canvas.clear()
    my_canvas.image(fname, y=imgy, x=None, scale=None, center=True)
    my_canvas.show()
    
    # run until the Enter key is pressed
    stop = False
    my_string = ""
    while not stop:
        # get keypress
        key, t1 = my_kb.get_key(timeout=None)
        # handle input
        if key.lower() in allowed:
            my_string += key
        elif key == 'space':
            my_string += " "
        elif key in ['enter','return']:
            stop = True
        # update display
        my_canvas.clear()
        my_canvas.image(fname, y=imgy, x=None, scale=None, center=True)
        my_canvas.text(my_string, center=True, color=None, max_width=None, html=True, bidi=None, y=txty, x=None)
        my_canvas.show()
    
    # save the string
    exp.set("response", my_string)
    

    Good luck!

    Edwin

  • edited 10:45AM

    Thanks Edwin!

  • edited 10:45AM

    No worries! Will mark this as solved.

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