Howdy, Stranger!

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

Supported by

TypeError: cannot unpack non-iterable NoneType object

Hi all

I've set an experiment requiring participants to respond to a stimulus by clicking on one of two on-screen button (regions).

The program crashes if there's no response after some seconds, although I;ve programmed no timeout. The error shown is: TypeError: cannot unpack non-iterable NoneType object.

The crash happens in both MacOs and Win10.

I've uploaded the script,

Any ideas?


Best ,

Fotis


Comments

  • Hi @fotisfotiadis ,


    I think by building in the following safety check the issue should disappear. Could you try? (See comments for details.)


    while True:
        # Use position instead of (x,y):
        # Set a (very low) timeout
        button, position, time = my_mouse.get_click(timeout = 20)
        
        # Built in this check:
        if button is not None:
            x,y = position
            # Indent one additional level
            if (x>-592 and x<-272 and y>-45 and y<45)\
                or (x>272 and x<592 and y>-45 and y<45):
                break
    


    Cheers,


    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • Dear Lotje


    I hadn't realised that, after all, I had set a timeout, by using the command my_mouse.set_timeout(10000)

    The comments in your code helped me spot that line in my code. Removing it fixed the problem.

    Thank you so much for your immediate response, I really appreciate it.


    Fotis

  • Hi there,

    I am actually experiencing a very similar problem: I changed the response modus in my experiment from keyboard to mouse response and would like to display an answer reminder after 30 seconds. That is why I set the mouse response timeout to 30 seconds. Unfortunately, I always receive the same error as described above:

    • TypeError: cannot unpack non-iterable NoneType object

    When I try the experiment without the answer reminder, everything is working fine, but when I wait for the 30 seconds to pass, the experiment crashes and I receive the error message.

    This is the answer reminder I am using (it actually worked fine when using it with keyboard responses):

    if button is None:

      my_canvas["answer_reminder"].color = "#f5f3ea"

      my_canvas.show()

      button, (x, y), time = my_mouse.get_click()

      my_canvas["answer_reminder"].color = "#4C4E52"

      my_canvas.show()

    I am creating the mouse function like this:

    my_mouse = Mouse(buttonlist=[1,3], timeout=mouse_timeout)

    and collect responses like this:

    button, (x, y), time = my_mouse.get_click()

    Did you figure out a way to solve this problem with a defined timeout or did you completely remove the timeout to solve the problem? Since I need the timeout for my answer reminder, is there any way I can solve this issue?

    Thanks a lot in advance!

    Best,

    Sarah

  • Hi Sarah,

    The problem is this line:

    button, (x, y), time = my_mouse.get_click()

    In case of a timeout, the middle return value of get_click() is None and not an (x,y) pair of coordinates. As None cannot be split into two parts (x and y), the error arises. What you could do instead, is to replace (x,y) with pos , followed by:

    if pos is None: 
       # draw warning canvas
    else: 
       x, y = pos
    


    Hope this helps,

    Eduard

    Buy Me A Coffee

  • Hi Eduard,

    Thank you so much! I actually replaced the (x,y) for position in all of the lines where I get a mouse response (button, position, time = my_mouse.get_click()) since the position does not matter in my experiment and now it works! :)

    Best,

    Sarah

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