本文整理汇总了Python中VisionEgg.FlowControl.Presentation.go方法的典型用法代码示例。如果您正苦于以下问题:Python Presentation.go方法的具体用法?Python Presentation.go怎么用?Python Presentation.go使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisionEgg.FlowControl.Presentation
的用法示例。
在下文中一共展示了Presentation.go方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: showImage
# 需要导入模块: from VisionEgg.FlowControl import Presentation [as 别名]
# 或者: from VisionEgg.FlowControl.Presentation import go [as 别名]
def showImage(screen, img, duration=1):
def quitKey(event):
if event.key == pygame.locals.K_SPACE:
quit()
def click(event):
quit()
def quit(dummy_arg=None):
image.parameters.go_duration = (0,'frames')
img = Image.open(img)
#create textures
tex = Texture(img)
x = screen.size[0] / 2
y = screen.size[1] / 2
stimulus = TextureStimulus(texture = tex, position = (x, y), anchor = 'center')
#create viewports
viewport = Viewport(screen=screen, stimuli=[stimulus])
if duration:
image = Presentation(go_duration=(duration, 'seconds'), viewports=[viewport])
else:
image = Presentation(go_duration=('forever', ''), viewports=[viewport])
image.parameters.handle_event_callbacks=[(pygame.locals.QUIT, quit),(pygame.locals.KEYDOWN, quitKey), (pygame.locals.MOUSEBUTTONDOWN, click)]
image.go()
示例2: initMe
# 需要导入模块: from VisionEgg.FlowControl import Presentation [as 别名]
# 或者: from VisionEgg.FlowControl.Presentation import go [as 别名]
class CVEggStimText:
# Some are overwritten by the init func. Here for reference
text = "NULL"
font_sz = 50
anchor = "center"
t = 1
tscale = "seconds"
# initme's arguments are : (text,font-sz,time,t-unit,screen)
def initMe(self, arg_text, arg_font_sz, arg_t, arg_tscale, arg_screen, arg_r=1.0, arg_g=1.0, arg_b=1.0):
# member vars init
self.text = arg_text
self.font_sz = arg_font_sz
self.t = arg_t
self.tscale = arg_tscale
self.color = (arg_r, arg_g, arg_b)
# dyn vars
text_vegg = Text(
text=self.text,
color=self.color,
position=(arg_screen.size[0] / 2, arg_screen.size[1] / 2),
font_size=self.font_sz,
anchor=self.anchor,
)
viewport_vegg = Viewport(screen=arg_screen, size=arg_screen.size, stimuli=[text_vegg])
# Set up the pres var
self.pres_vegg = Presentation(go_duration=(arg_t, arg_tscale), viewports=[viewport_vegg])
def show(self):
# print self.text_vegg
self.pres_vegg.go()
示例3: showStimulus
# 需要导入模块: from VisionEgg.FlowControl import Presentation [as 别名]
# 或者: from VisionEgg.FlowControl.Presentation import go [as 别名]
def showStimulus(screen, text, colour):
word, viewport = printWord(screen, text, 200, colour)
p = Presentation(go_duration=(0.5,'seconds'),viewports=[viewport])
p.go()
start = time.clock()
exit = 0
while not exit:
data = raw_lpt_module.inp(0x379) & 0x20
if not data:
RT = time.clock()
p.parameters.go_duration = (0.032, 'seconds')
#dataList.append ([text, colour, start, RT])
exit = 1
else:
pass
示例4: showStimulus
# 需要导入模块: from VisionEgg.FlowControl import Presentation [as 别名]
# 或者: from VisionEgg.FlowControl.Presentation import go [as 别名]
def showStimulus(screen, text, colour, useLPT=True):
word, viewport = printWord(screen, text, 200, colour)
p = Presentation(go_duration=(stroopDuration,'seconds'),viewports=[viewport])
if useLPT:
p.go()
start = time.clock()
exit = 0
while not exit:
data = raw_lpt_module.inp(0x379) & 0x20
#print data
if not data:
#print "hello"
RT = time.clock()
p.parameters.go_duration = (blank, 'seconds')
subject.inputData(trial, "text", text)
subject.inputData(trial, "colour", colour)
subject.inputData(trial, "RT", RT)
exit = 1
else:
pass
示例5: showInstructions
# 需要导入模块: from VisionEgg.FlowControl import Presentation [as 别名]
# 或者: from VisionEgg.FlowControl.Presentation import go [as 别名]
def showInstructions(screen, text, textSize=60, textcolor=(255, 255, 255)):
#create our instruction screen
#load up the instruction text
insStim, insView = printText(screen, text, textSize, textcolor)
instructions = Presentation(go_duration=('forever',), viewports=[insView])
#add a quit function and a handler to go with it
def quitKey(event):
if event.key == pygame.locals.K_SPACE:
quit()
def click(event):
quit()
def quit(dummy_arg=None):
instructions.parameters.go_duration = (0,'frames')
instructions.parameters.handle_event_callbacks=[(pygame.locals.QUIT, quit),(pygame.locals.KEYDOWN, quitKey), (pygame.locals.MOUSEBUTTONDOWN, click)]
#show instructions
instructions.go()
示例6: VisualSpellerVE
# 需要导入模块: from VisionEgg.FlowControl import Presentation [as 别名]
# 或者: from VisionEgg.FlowControl.Presentation import go [as 别名]
class VisualSpellerVE(MainloopFeedback):
"""
Visual Speller with six circles like the classical HexOSpell.
"""
# Triggers: look in Marker
END_LEVEL1, END_LEVEL2 = 244, 245 # end of hex levels
COPYSPELLING_FINISHED = 246
STIMULUS = [[11, 12, 13, 14, 15, 16], [21, 22, 23, 24, 25, 26]]
RESPONSE = [[51, 52, 53, 54, 55, 56], [61, 62, 63, 64, 65, 66]]
TARGET_ADD = 20
ERROR_ADD = 100
COUNTDOWN_STIMULI = 239
ERROR_POTENTIAL = 96 # send if error potential is classified
def init(self):
"""
initialize parameters
"""
self.log_filename = "VisualSpellerVE.log"
self.geometry = [0, 0, 1280, 800] ## size
self.letterbox_size = (60, 60)
self.osc_size = 40
self.font_size_phrase = 60 # the spelled phrase at the top
self.font_size_current_letter = 80 # the spelled phrase at the top
self.font_size_countdown = 150 # number during countdown
self.desired_phrase = ""
## colors:
self.bg_color = (0.0, 0.0, 0.0)
self.phrase_color = (0.2, 0.0, 1.0)
self.current_letter_color = (1.0, 0.0, 0.0)
self.countdown_color = (0.2, 0.0, 1.0)
self.osc_color = (1, 1, 1)
self.letter_set = [
["A", "B", "C", "D", "E"],
["F", "G", "H", "I", "J"],
["K", "L", "M", "N", "O"],
["P", "Q", "R", "S", "T"],
["U", "V", "W", "X", "Y"],
["Z", "_", ".", ",", "<"],
]
self.fullscreen = False
self.use_oscillator = True
self.offline = True
self.copy_spelling = True # in copy-spelling mode, selection of the target symbol is forced
self.debug = False
self.nCountdown = 5
self.nr_sequences = 6
self.randomize_sequence = True # set to False to present a fixed stimulus sequence
self.min_dist = 2 # Min number of intermediate flashes bef. a flash is repeated twice
self.stimulus_duration = 0.083 # 5 frames @60 Hz = 83ms flash
self.interstimulus_duration = 0.1
self.animation_time = 1
self.wait_before_classify = 1.0
self.feedback_duration = 1.0
self.feedback_ErrP_duration = 1.0
self.wait_after_start = 0.0
# Countdown options
self.do_animation = True
self.synchronized_countdown = True
if self.synchronized_countdown:
self.do_animation = False
self.countdown_level1 = True
self.countdown_level2 = True
self.countdown_shapes = {"circle": FilledCircle, "hexagon": FilledHexagon}
self.countdown_shape_select = "hexagon"
self.countdown_shape_color = (0.7, 0.7, 0.7)
self.countdown_shape_on = True
self.countdown_blinking_nr = 5 # number of pre-sequence stimuli(1 sec is approx. 5 frames at 60 Hz)
self.wait_after_early_stopping = 3 # sec
self.abort_trial = False
self.output_per_stimulus = True
self.use_ErrP_detection = False
self.serialtrigger = False
self.serialport = serialport.SerialPort(13)
self.send_parallel_bak = self.send_parallel
if self.debug:
msg = "!!! YOU'RE IN DEBUG MODE! CLASSIFICATION WILL BE RANDOM OR KEYBOARD CONTROLLED !!!"
self.logger.warning(msg)
def pre_mainloop(self):
## logging
assert len(self.log_filename) != 0 # 'log_filename' must not be empty string!
logger.setLevel(logging.ERROR)
handler = logging.FileHandler(self.log_filename, "w")
handler.setLevel(logging.INFO)
formatter = logging.Formatter("%(asctime)s: %(message)s")
handler.setFormatter(formatter)
#.........这里部分代码省略.........
示例7: printWord
# 需要导入模块: from VisionEgg.FlowControl import Presentation [as 别名]
# 或者: from VisionEgg.FlowControl.Presentation import go [as 别名]
# default strategy
strategy = None
trial = 1
# STIMULI
# Fixation Cross
fixText, fixCross = printWord(screen, "*", 120, (255, 255, 255))
errorText, errorPort = printWord(screen, "X", 120, (1.0, 0.1, 0.1))
print "PRESS SPACE TO START"
pause = Presentation(go_duration=("forever",), viewports=[fixCross])
pause.parameters.handle_event_callbacks = [(pygame.locals.KEYDOWN, pause_handler)]
pause.go()
problemQ = []
while len(mag_problems):
if problemQ:
stim = problemQ[2]
n1 = problemQ[0]
n2 = problemQ[1]
else:
p = mag_problems.pop(0)
n1 = p[0]
n2 = p[1]
symbol = " OR "
solution = str(max([n1, n2]))
示例8: printWord
# 需要导入模块: from VisionEgg.FlowControl import Presentation [as 别名]
# 或者: from VisionEgg.FlowControl.Presentation import go [as 别名]
#default strategy
strategy = None
#default empty problem
ns = []
lastns = []
lastlastns = []
fixText, fixCross = printWord(screen, '', 120, (255, 255, 255))
print "PRESS SPACE TO START"
pause = Presentation(go_duration=('forever', ), viewports=[fixCross])
pause.parameters.handle_event_callbacks=[(pygame.locals.KEYDOWN, pause_handler)]
pause.go()
while len(memProblems) < trials or len(calcProblems) < trials:
#generate problem based on last round
random.shuffle(add)
random.shuffle(subtract)
random.shuffle(memAdd)
badProblem = True
#if the heap is half full, definitely check
if len(problemHeap) >= (trials/3):
verify = 1
elif len(calcProblems) >= trials and len(problemHeap) > 3:
verify = 1
#if we have all our memory problems and there are a few in the heap
示例9: TextureStimulus
# 需要导入模块: from VisionEgg.FlowControl import Presentation [as 别名]
# 或者: from VisionEgg.FlowControl.Presentation import go [as 别名]
# setup main experimental loop
loadStims = 0
wrote_response = 0
stimulus = TextureStimulus(
anchor="center",
size=stimuli_size,
position=(screen.size[0] / 2.0, screen.size[1] / 2.0),
texture_min_filter=gl.GL_LINEAR,
shrink_texture_ok=1,
# PW 2012/11/26
mipmaps_enabled=False,
)
# p = Presentation(go_duration=(trial_dur*len(exp_plan), 'seconds'), viewports=[viewport_fixation])
p = Presentation(go_duration=(num_blocks * block_len, "seconds"), viewports=[viewport_fixation])
p.parameters.handle_event_callbacks = [(pygame.locals.KEYDOWN, keydown)]
p.add_controller(None, None, FunctionController(during_go_func=oneTrial))
# p.add_controller(stimulus,'position', FunctionController(during_go_func=get_target_position) )
exp_start_time = time.time()
p1.go()
exp_start_time = time.time()
p.go()
exp_end_time = time.time()
print exp_end_time - exp_start_time
datafile.close
示例10: aplicacion
# 需要导入模块: from VisionEgg.FlowControl import Presentation [as 别名]
# 或者: from VisionEgg.FlowControl.Presentation import go [as 别名]
def aplicacion():
global p,inten,coord
pos=[0.4,0.5,0.6,0.7,0.8]
pos2=[1.3,1.4,1.5,1.6,1.7,1.8]
rellenar()
shuffle(coord)
i = len(coord)-1
target.parameters.position = coord[i][:2]
(xpos,ypos)=target.parameters.position
x=xpos-screen.size[0]/2
y=ypos-screen.size[1]/2
anrad=math.atan2(y, x)
angrad=math.degrees(anrad)
if angrad>=0:
if angrad<=90:
orientacion=-45
xx=2.0
yy=2.0
else:
orientacion=-135
xx=-2.0
yy=2.0
else:
aux=angrad*(-1)
if aux<=90:
orientacion=45
xx=2.0
yy=-2.0
else:
orientacion=135
xx=-2.0
yy=-2.0
fixpoint.parameters.position=((screen.size[0]/2.0)+xx, (screen.size[1]/2.0)+yy)
fixpoint.parameters.orientation=orientacion
viewport = Viewport(screen=screen, stimuli=[fixpoint,fixcirc])
p = Presentation(go_duration=(1.0,'seconds'),viewports=[viewport])
p.parameters.handle_event_callbacks = [(pygame.locals.KEYDOWN, keydown),
(pygame.locals.KEYUP, keyup),
(pygame.locals.QUIT, quit_app)]
p.add_controller(None, None, FunctionController(during_go_func=settings))
#winsound.PlaySound('instruccion',winsound.SND_FILENAME)
p.go()
while len(coord)!= 0:
if end:
break
i = len(coord)-1
target.parameters.position = coord[i][:2]
dur=pos[random.randrange(0,4,1)]
(xpos,ypos)=target.parameters.position
x=xpos-screen.size[0]/2
y=ypos-screen.size[1]/2
anrad=math.atan2(y, x)
angrad=math.degrees(anrad)
#fixpoint.parameters.orientation=(-angrad)
if angrad>=0:
if angrad<=90:
orientacion=-45
xx=2.0
yy=2.0
else:
orientacion=-135
xx=-2.0
yy=2.0
else:
aux=angrad*(-1)
if aux<=90:
orientacion=45
xx=2.0
yy=-2.0
else:
orientacion=135
xx=-2.0
yy=-2.0
fixpoint.parameters.position=((screen.size[0]/2.0)+xx, (screen.size[1]/2.0)+yy)
fixpoint.parameters.orientation=orientacion
viewport = Viewport(screen=screen, stimuli=[fixpoint,fixcirc])
p = Presentation(go_duration=(dur,'seconds'),viewports=[viewport])
p.parameters.handle_event_callbacks = [ (pygame.locals.QUIT, quit_app)]
p.add_controller(None, None, FunctionController(during_go_func=settings))
p.go()
inten = coord[i][-1]
target.parameters.color = (1.0,1.0,1.0,inten) #Se muestra el estimulo Duracion 0.3 segundos
viewport = Viewport(screen=screen, stimuli=[target,fixpoint,fixcirc])
p = Presentation(go_duration=(0.3,'seconds'),viewports=[viewport])
p.parameters.handle_event_callbacks = [ (pygame.locals.QUIT, quit_app)]
p.add_controller(None, None, FunctionController(during_go_func=settings))
p.go()
target.parameters.color = (0.0,0.0,0.0,1.0) #Desaparece el estimulo tiempo para registrar
#.........这里部分代码省略.........
示例11: __init__
# 需要导入模块: from VisionEgg.FlowControl import Presentation [as 别名]
# 或者: from VisionEgg.FlowControl.Presentation import go [as 别名]
class SimpleVisionEgg:
keyboard_controller = None
trigger_controller = None
screen = None
presentation = None
keys = None
presses = None
releases = None
def __init__(self):
"""We break up initialization a bit as we need to go back and forth with
some information. In this case, we need screen size before specifying
the stimuli"""
# pasted in from where it used to be at the beginning of the script
# used to be outside of any methods...
VisionEgg.start_default_logging()
VisionEgg.watch_exceptions()
# get screen size for setting fullscreen resolution
# comment this block out if you don't want to use full-screen.
screen = pygame.display.set_mode((0,0))
WIDTH, HEIGHT = screen.get_size()
pygame.quit()
VisionEgg.config.VISIONEGG_SCREEN_W = WIDTH
VisionEgg.config.VISIONEGG_SCREEN_H = HEIGHT
self.screen = get_default_screen()
self.keys = []
self.presses = []
self.releases = []
def set_stimuli(self, stimuli, trigger=None, kb_controller=False):
"""Now that we have our stimuli, we initialize everything we can"""
viewport = Viewport(screen=self.screen, size=self.screen.size,
stimuli=stimuli)
# We disable "check_events" so that we don't lose "instantaneous" key
# presses and can check these in our Response classes
self.presentation = Presentation(viewports=[viewport],
check_events=False)
if trigger:
trigger_controller = KeyboardTriggerInController(trigger)
self.presentation.add_controller(self.presentation,
'trigger_go_if_armed', trigger_controller)
self.presentation.set(trigger_go_if_armed=0)
if kb_controller:
self.keyboard_controller = KeyboardResponseController()
self.presentation.add_controller(None, None, self.keyboard_controller)
def set_functions(self, update=None, pause_update=None):
"""Interface for cognac.StimulusController or similar"""
self.presentation.add_controller(None, None,
FunctionController(during_go_func=update,
between_go_func=pause_update,
return_type=NoneType) )
def go(self, go_duration=('forever',)):
self.presentation.parameters.go_duration = go_duration
self.presentation.go()
def pause(self):
self.presentation.parameters.go_duration = (0, 'frames')
def get_new_response(self, t, min_interval=2.0 / 60, releases=False):
"""(key, press) = get_new_response(self, t, min_interval=2.0 / 60)
DEPRECATED!
Use this function to get responses from the keyboard controller in real
time.
Returns (None, None) if no new response is available.
Maintains three instance variables - keys, presses and releases, which
you can also access directly (but they won't be updated during loops
where you don't call this function)
This function makes a number of assumptions and is a little brittle
right now. By not hard-coding the min_interval and maybe using key
presses and release events directly, we'd have a much better function.
But I don't really care right now.
DJC
"""
raise DeprecationWarning("please use pygame directly, as in" +
"StimController.Response")
# Note - this is deprecated anyway, but it'd probably make more sense to
# use the keyboard_controller.get_responses() to simply get the keys
# that are down _right_now_
press_time = self.keyboard_controller.get_time_last_response_since_go()
key = self.keyboard_controller.get_last_response_since_go()
# Our first response!
if len(self.keys) == 0:
if key:
self.keys.append(key)
self.presses.append(press_time)
#.........这里部分代码省略.........
示例12: TR
# 需要导入模块: from VisionEgg.FlowControl import Presentation [as 别名]
# 或者: from VisionEgg.FlowControl.Presentation import go [as 别名]
class TRStimController:
"""This is a relatively simple controller that simply updates what's on the
screen every TR (which is the next occurrence of keyboard input of '5' after
the TR length is exceeded. Currently it sets one stimulus on, and all
others off, though we may want to change that to turn a list of stimuli on
eventually"""
# 3T laptop forp sends TTL pulses as "5"; buttons as "1","2","3","4"
# John used to do things this way:
# trigger_in_controller = KeyboardTriggerInController(pygame.locals.K_5)
# Expected length of 1 TR
TR = 2.0
# Time interval after which we assume we missed the trigger
eps = 0.1
t = 0
trial_times = None
missed_trigs = None
stim_list = []
stim_dict = {}
stim_seq = []
keyboard_controller = None
presentation = None
screen = None
def __init__(self, TR=None, eps=None):
# Get the initial setup
if TR:
self.TR = TR
if eps:
self.eps = eps
self.trial_times = []
self.missed_trigs = []
self.state = self.state_generator()
self.screen = get_default_screen()
# background black (RGBA)
self.screen.parameters.bgcolor = (0.0,0.0,0.0,0.0)
self.keyboard_controller = KeyboardResponseController()
self.firstTTL_trigger = KeyboardTriggerInController(K_5)
def set_stims(self, stim_list, stim_dict, stim_seq_file):
self.stim_list = stim_list
self.stim_dict = stim_dict
self.stim_seq = yaml.load(stim_seq_file)
viewport = Viewport(screen=self.screen,
size=self.screen.size,
stimuli=self.stim_list)
# Need to at least wait for the first trigger if this is going to work.
go_duration = (self.TR * len(self.stim_seq), 'seconds')
self.presentation = Presentation(go_duration=go_duration,
trigger_go_if_armed=0,
viewports=[viewport])
self.presentation.add_controller(None, None,
FunctionController(during_go_func=self.update) )
self.presentation.add_controller(None, None, self.keyboard_controller)
# Adding this so that we can start the stimuli ahead of time
self.presentation.add_controller(self.presentation,'trigger_go_if_armed',
self.firstTTL_trigger)
def run(self):
self.presentation.go()
self.screen.close()
def update(self, t):
self.t = t
try:
self.state.next()
except StopIteration:
# shouldn't really happen, what with epsilon and all...
self.blank_all_stims()
def blank_all_stims(self):
for stim in self.stim_list:
stim.parameters.on=False
def state_generator(self):
for stim_info in self.stim_seq:
self.trial_times.append(self.t)
self.blank_all_stims()
try:
for stim_name, params in stim_info.items():
stim = self.stim_dict[stim_name]
stim.parameters.on = True
try:
for name, value in params.items():
setattr(stim.parameters, name, value)
except AttributeError:
# params was None or something else we don't deal with
pass
except AttributeError:
# We assume a no-colon single token / key
self.stim_dict[stim_info].parameters.on = True
#.........这里部分代码省略.........
示例13: __init__
# 需要导入模块: from VisionEgg.FlowControl import Presentation [as 别名]
# 或者: from VisionEgg.FlowControl.Presentation import go [as 别名]
class Stimulation:
global TopRate, BotRate, LeftRate, RightRate, HSize, VSize
global numTrial, order_appear
global duration_init, duration_cue, duration_target, duration_trial, total_time
# Set up stimulus's frequency
TopRate = 5 # Hz
BotRate = 10
LeftRate = 15
RightRate = 20
# Set dimension of the targets
HSize = 100
VSize = 50
# Experiment parameters
numTrial = 4
order_appear = np.uint16(4*np.random.random(numTrial)+1)
duration_init = 2
duration_target = 3
duration_cue = 2
duration_trial = duration_target + duration_cue
total_time = duration_init + duration_trial*numTrial
def __init__(self):
global w, h
self._running = True
# Initialize screen
# TODO
# Set fullscreen
self.screen = get_default_screen()
# Get dimension of the screen
w = self.screen.size[0]
h = self.screen.size[1]
# Initialize Targets
self.TopTarget = Target2D()
self.BotTarget = Target2D()
self.LeftTarget = Target2D()
self.RightTarget = Target2D()
# Message
self.mess = Text(text='Please wait for next trial...',
color=(1.0, 0.5, 0.5),
position=(w/2, h*0.8),
font_size=50,
anchor='center',
on=True)
# Arrows
self.arrow = TextureStimulus()
# Viewports to stick graphical objects to screen
self.viewport1 = Viewport(screen=self.screen,
stimuli=[self.TopTarget, self.BotTarget, self.LeftTarget, self.RightTarget]) # For Targets
self.viewport2 = Viewport(screen=self.screen,
stimuli=[self.arrow]) # For cue (and other things)
self.viewport3 = Viewport(screen=self.screen,
stimuli=[self.mess]) # For cue (and other things)
# Presentations (for controlling timing)
self.initialize = Presentation(go_duration=(duration_init, 'seconds'), viewports=[self.viewport3])
self.targetShow = Presentation(go_duration=(duration_target, 'seconds'), viewports=[self.viewport1])
self.cueShow = Presentation(go_duration=(duration_cue, 'seconds'), viewports=[self.viewport2])
# For result
self.TargetLog = np.zeros((numTrial, 2)) # First column: target code,
def on_init(self):
# Set screen's background color
self.screen.set(bgcolor=(0., 0., 0.)) # black
# Set target's properties
self.TopTarget.set(size=(HSize, VSize),
color= (1.0, 1.0, 1.0, 1.0),
position=(w/2, h*0.8))
self.BotTarget.set(size=(HSize, VSize),
color=(1.0, 1.0, 1.0, 1.0),
position=(w/2, h*0.2))
self.LeftTarget.set(size=(VSize, HSize),
color=(1.0, 1.0, 1.0, 1.0),
position=(w*0.2, h/2))
self.RightTarget.set(size=(VSize, HSize),
color=(1.0, 1.0, 1.0, 1.0),
position=(w*0.8, h/2))
# Message
# self.text.set(text='Please wait for next trial...',
# color=(1.0, 0.5, 0.5),
# position=(w/2, h*0.8),
# font_size=50,
# anchor='center',
# on=False)
# Arrows
self.arrow.set(texture=Texture('images\left2.bmp'),
position=(w/2, h/2),
anchor='center',
on=False)
#.........这里部分代码省略.........
示例14: while
# 需要导入模块: from VisionEgg.FlowControl import Presentation [as 别名]
# 或者: from VisionEgg.FlowControl.Presentation import go [as 别名]
count = 0
while (count<len(introTexts)): # DJ CHANGE 4/23/12
# Create a Viewport instance (initialized just to display instructions)
viewport = Viewport(screen=screen, stimuli=[introTexts[count], introTexts_bottomline[count]])
# Create an instance of the Presentation class. (Runtime control)
# note that timeBetweenBlocks/2 is used here to match the time of each between-block frame.
p = Presentation(go_duration=(timeBetweenBlocks/2,'seconds'), viewports=[viewport])
# Register Event Handlers so we can speed things up or quit early if we need to
p.parameters.handle_event_callbacks = \
[(pygame.locals.QUIT, quit), (pygame.locals.KEYDOWN, keydown), (pygame.locals.KEYUP, keyup)]
p.between_presentations()
p.go()
count = count+1
#####################################################################
## Here the intro text is complete, entering the image block loop ##
#####################################################################
#imageTex = Texture('white.jpg') # To be made generic
try:
示例15: VisionEggView
# 需要导入模块: from VisionEgg.FlowControl import Presentation [as 别名]
# 或者: from VisionEgg.FlowControl.Presentation import go [as 别名]
#.........这里部分代码省略.........
return txt
def add_image_stimulus(self, **kw):
if not kw.has_key('anchor'):
kw['anchor'] = 'center'
img = TextureStimulus(**kw)
self.add_stimuli(img)
return img
def _create_color(self, name):
try:
if isinstance(name, tuple):
return Color(*name).normalize()
else:
return Color(str(name)).normalize()
except ValueError:
self._logger.warn('No such pygame.Color: %s' % str(name))
def _set_font_color(self):
""" Set the standard font color by pygame name. """
self._font_color = (self._create_color(self._font_color_name) or
Color(1, 1, 1, 255).normalize())
def _set_bg_color(self):
""" Set the standard background color by pygame name. """
c = (self._create_color(self._bg_color) or
Color(0, 0, 0, 255).normalize())
self.screen.set(bgcolor=c)
def present_frames(self, num_frames):
""" Launch the presentation main loop for a given number of
frames.
"""
self.presentation.set(go_duration=(num_frames, 'frames'))
self.presentation.go()
def present(self, sec):
self.presentation.set(go_duration=(sec, 'seconds'))
self.presentation.go()
def update(self):
""" Repaint the canvas for one frame to update changed stimuli.
"""
self.present_frames(1)
def center_word(self, text, color=None):
""" Set the standard word in the screen center. """
self._center_text.set(text=text)
self._center_text.set(colors=color or (self._font_color for l in
self._center_text))
def clear_center_word(self):
""" Remove the center word from the screen. """
self.center_word('')
self.update()
def present_center_word(self, text, seconds, color=None):
self.center_word(text, color)
self.present(seconds)
self.clear_center_word()
def ask(self, question=True):
""" Loop indefinitely until answered() is called. If question is
True, a question mark is shown in the center.
"""
if question: