Copy sketchpad in 3.1.2
Hi All,
I am trying to set the canvas "my_target_canvas" to pull up a different canvas depending on what the variable "target_pic" is. I've tried doing this below, but I'm getting an error when it tries to run through the code. All of the sketchpads have been created elsewhere and are being called up by name in the code. Can you see something that might be a problem here or have suggestions for fixing? Of note is that I only just updated to 3.1.2 and had been running on an older version with a similar code except only one possible target, and that code worked in the previous version, so I'm not sure if it's something with the update.
Thanks for the help!
Kristin
`#draw fixation screen canvas
from openexp.canvas import canvas
my_fix_canvas = canvas(exp)
draw boxes and fixation
my_fix_canvas = self.copy_sketchpad('fixation')
my_fix_canvas.prepare()
copy target sketchpad
if var.target_pic == "lightning":
my_target_canvas = canvas(exp)
my_target_canvas = self.copy_sketchpad('target_lightning')
my_target_canvas.prepare()
else:
if var.target_pic == "star":
my_target_canvas = canvas(exp)
my_target_canvas = self.copy_sketchpad('target_star')
my_target_canvas.prepare()
else:
if var.target_pic == "arrow":
my_target_canvas = canvas(exp)
my_target_canvas = self.copy_sketchpad('target_arrow')
my_target_canvas.prepare()
else:
if var.target_pic == "flag":
my_target_canvas = canvas(exp)
my_target_canvas = self.copy_sketchpad('target_flag')
my_target_canvas.prepare()
else:
if var.target_pic == "8point_star":
my_target_canvas = canvas(exp)
my_target_canvas = self.copy_sketchpad('target_8point_star')
my_target_canvas.prepare()
else:
if var.target_pic == "moon":
my_target_canvas = canvas(exp)
my_target_canvas = self.copy_sketchpad('target_moon')
my_target_canvas.prepare()
else:
if var.target_pic == "triangle":
my_target_canvas = canvas(exp)
my_target_canvas = self.copy_sketchpad('target_triangle')
my_target_canvas.prepare()
else:
if var.target_pic == "heart":
my_target_canvas = canvas(exp)
my_target_canvas = self.copy_sketchpad('target_heart')
my_target_canvas.prepare()
`
Comments
Maybe this helps:
http://osdoc.cogsci.nl/3.1/important-changes-3/#no-more-from-openexp-import
Best,
Jarik
What's clearly missing in your question is the actual error! Details please.
In any case, the script that you posted is incorrect Python because the indentation is invalid; that is,
else
should always be preceded by just as many tabs as theif
that it belongs to. You can enable script validation ('Validate content') in OpenSesame to see which lines are incorrect and why (insofar as the validation can detect this, of course):Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!