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): breakCheers,
Lotje
Did you like my answer? Feel free to

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:
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)withpos, followed by:Hope this helps,
Eduard
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