def init_episode(): #assign an order to the stimuli; the index is the item label and the value is the order position userlog.append([]) global stim_order,stim stim=[[]] shuffle(stim_order) print stim_order for i in range(num_stim): label=pyglet.text.Label(str(i), font_name='Times New Roman', font_size=36, x=x_pos(0), y=y_pos(i), anchor_x='center', anchor_y='center', batch=batch) ssprite=SelectableSprite(image,x_pos(0),y_pos(i),batch=batch,label=label) ssprite.color=(randint(0,255),randint(0,255),randint(0,255)) ssprite.scale=image_scale (pos,s)=(stim_order[i],ssprite) stim[0].append((pos,s)) window.push_handlers(s.on_mouse_press) window.push_handlers(s.on_mouse_drag)
def set_stim_pos(): for lst in stim: for (pos,obj) in lst: obj.x=obj.label.x=x_pos(stim.index(lst)) obj.y=obj.label.y=y_pos(lst.index((pos,obj))) # pdb.set_trace() def new_lst((pos,obj),lst): # pdb.set_trace() #copy the list lst_copy=[] for (lpos,lobj) in lst[1:]: label=pyglet.text.Label(lobj.label.text, font_name='Times New Roman', font_size=36, x=x_pos(0), y=y_pos(lst.index((lpos,lobj))), anchor_x='center', anchor_y='center', batch=batch) s=SelectableSprite(lobj.image,x_pos(0),y_pos(lst.index((lpos,lobj))),batch=batch,label=label) s.scale=lobj.scale s.color=lobj.color lst_copy.append((lpos,s)) window.push_handlers(s.on_mouse_press) window.push_handlers(s.on_mouse_drag) lst_copy.insert(0,(pos,obj)) return lst_copy pyglet.app.run() # def less(a,b): # pdb.set_trace() # return stim_order.index(a) < stim_order.index(b)