isPressedIn problems

168 views
Skip to first unread message

Dann Albright

unread,
Jan 16, 2014, 10:36:30 AM1/16/14
to psychop...@googlegroups.com
I'm trying to update a message based on if there's been a mouse click in the correct location, but it's not working. I've tried a few different things with no success (you can see my code below). Is isPressedIn part of a particular dependency?

Begin experiment:

import pygame
import pyglet
mouse = event.Mouse()
message1=" "
message2=" "
color1="black"
color2="black"

Each frame:

if mouse.isPressedIn(shape_a):
    color1="green"
    message1="good job!"

It's entirely possible (quite likely, in fact) that I'm missing something obvious. Thanks for any help you can provide!

Jared Roberts

unread,
Jan 16, 2014, 12:40:21 PM1/16/14
to psychop...@googlegroups.com
Hi Dann,

Do you happen to have an else statement that resets those values if the mouse button is not pressed in?  My intuition here is that it's setting your values correctly on the frame when the mouse button is depressed, but then resetting them the first frame after the button is up. 

__
Jared Roberts
Graduate Student
The Yassa Aging and Memory Laboratory
University of California, Irvine
"A lost cause can be as spiritually satisfying as a victory." - Robert Heinlein

Dann Albright

unread,
Jan 17, 2014, 2:54:00 AM1/17/14
to psychop...@googlegroups.com
That's a really great thought! I think that's probably one of the issues that I was having. I changed the "else" statement so that it doesn't affect color1 or message1.

However, after fixing that, it still wasn't having the desired effect. I checked the log file, and the clicks are registering, but the message isn't getting set by the click. The clicks are getting registered, but there's no response listed to the clicks—the message doesn't update. Here's that part of the log:

13.3744 EXP MovieStim: autoDraw = None
13.5563 EXP MovieStim: autoDraw = None
19.5528 EXP MovieStim: autoDraw = None
19.7537 EXP MovieStim: autoDraw = None
25.4239 EXP ImageStim: autoDraw = None
25.4239 EXP ImageStim: autoDraw = None
25.4239 EXP TextStim: autoDraw = None
25.4239 EXP TextStim: autoDraw = None
25.4239 EXP Rect: autoDraw = None
25.7671 EXP MovieStim: autoDraw = None
26.2789 DATA Mouse: Left button down, pos=(332,174)
26.2869 DATA Mouse: Left button up, pos=(332,174)
27.8724 DATA Mouse: Left button down, pos=(332,174)
29.2551 EXP New trial (rep=0, index=1): {u'triad': 3, u'videob': u'walk25low.mp4', u'videoa': u'walk13high.mp4', u'correct': u'optionb', u'videox': u'walk7mid.mp4'}



Any other ideas?

Jared Roberts

unread,
Jan 17, 2014, 12:34:27 PM1/17/14
to psychop...@googlegroups.com
Hi Dann,

I would suggest putting a print statement inside of that if statement to see if it ever gets in there.  Also, where do you define shape_a?  What type of stimulus is it?

--

Dann Albright

unread,
Jan 21, 2014, 5:20:09 AM1/21/14
to psychop...@googlegroups.com
I put a print statement in there, but I didn't see it show up anywhere. Where would I expect to see that? In the log file? (I'm a bit inexperienced with debugging the code component.)

shape_a is a polygon that I used the builder view to create. It's just a rectangle that I'm using as a button. I've attached the .psyexp and lastrun.py files, in case those are of any help.

Thanks for your assistance with this—I really appreciate it!
training_cond1.psyexp
training_cond1_lastrun.py

Dann Albright

unread,
Jan 21, 2014, 5:52:02 AM1/21/14
to psychop...@googlegroups.com
Ah ha! I think I have it figured out. I was looking through old threads, and I found that someone had previously had an issue with using different units in different settings throughout the experiment. I changed all of the textstims, polygons, and the experiment settings to cm, and that seems to have solved the problem. The experiment was set to 'use prefs'.
Reply all
Reply to author
Forward
0 new messages