|
3 | 3 | from smile.scale import scale as s |
4 | 4 | from .GetResponse import GetResponse |
5 | 5 |
|
| 6 | + |
| 7 | +def get_is_first(run_num): |
| 8 | + return run_num == 0 |
6 | 9 | # present instructions |
7 | 10 | @Subroutine |
8 | | -def Instruct(self, config, text_names):#, resp_keys, touch, font_size): |
| 11 | +def Instruct(self, config, text_names, run_num):#, resp_keys, touch, font_size): |
| 12 | + |
| 13 | + is_first = Func(get_is_first, run_num).result |
9 | 14 |
|
10 | 15 | texts = get_text(config) |
11 | | - with Parallel(): |
12 | | - if not config.TOUCH: |
13 | | - MouseCursor(blocking=False) |
14 | | - with Serial(blocking=False): |
15 | | - for doc in text_names: |
16 | | - with Parallel(): |
17 | | - title = Label(text='Memory Task Instructions', |
18 | | - font_size=s(config.INST_TITLE_FONT_SIZE), |
| 16 | + with If(is_first): |
| 17 | + with Parallel(): |
| 18 | + if not config.TOUCH: |
| 19 | + MouseCursor(blocking=False) |
| 20 | + with Serial(blocking=True): |
| 21 | + for doc in text_names: |
| 22 | + with Parallel(): |
| 23 | + title = Label(text='Memory Task Instructions', |
| 24 | + font_size=s(config.INST_TITLE_FONT_SIZE), |
| 25 | + text_size=(s(config.TEXT_SIZE_WIDTH), None), |
| 26 | + top=self.exp.screen.center_y + s(415)) |
| 27 | + |
| 28 | + # image != None for 4 example slides |
| 29 | + with If(texts[doc]['image'] != None): |
| 30 | + image = Image(source=texts[doc]['image'], |
| 31 | + top=(title.bottom - s(10)), |
| 32 | + width=s(config.INST_IMG_WIDTH), |
| 33 | + height=s(config.INST_IMG_HEIGHT), |
| 34 | + allow_stretch=True, keep_ratio=False) |
| 35 | + with If(texts[doc]['image'] != None): |
| 36 | + Label(text=texts[doc]['text'], |
| 37 | + font_size=s(config.INST_FONT_SIZE), |
| 38 | + text_size=(s(config.TEXT_SIZE_WIDTH), None), |
| 39 | + top=(image.bottom - s(10))) |
| 40 | + |
| 41 | + # image == None for first and last slides (instructions and reminder) |
| 42 | + with If(texts[doc]['image'] == None): |
| 43 | + Label(text=texts[doc]['text'], |
| 44 | + text_size=(s(config.TEXT_SIZE_WIDTH), None), |
| 45 | + font_size=s(config.INST_FONT_SIZE), |
| 46 | + top=(title.bottom - s(10))) |
| 47 | + |
| 48 | + with UntilDone(): |
| 49 | + Wait(1.0) |
| 50 | + GetResponse(keys=texts[doc]['keys']) |
| 51 | + |
| 52 | + with Else(): |
| 53 | + with Parallel(): |
| 54 | + if not config.TOUCH: |
| 55 | + MouseCursor(blocking=False) |
| 56 | + with Serial(blocking=False): |
| 57 | + for doc in text_names: |
| 58 | + with Parallel(): |
| 59 | + title = Label(text='Memory Task Instructions', |
| 60 | + font_size=s(config.INST_TITLE_FONT_SIZE), |
| 61 | + text_size=(s(config.TEXT_SIZE_WIDTH), None), |
| 62 | + top=self.exp.screen.center_y + s(415)) |
| 63 | + |
| 64 | + # image != None for 4 example slides |
| 65 | + with If(texts[doc]['image'] != None): |
| 66 | + image = Image(source=texts[doc]['image'], |
| 67 | + top=(title.bottom - s(10)), |
| 68 | + width=s(config.INST_IMG_WIDTH), |
| 69 | + height=s(config.INST_IMG_HEIGHT), |
| 70 | + allow_stretch=True, keep_ratio=False) |
| 71 | + with If(texts[doc]['image'] != None): |
| 72 | + Label(text=texts[doc]['text'], |
| 73 | + font_size=s(config.INST_FONT_SIZE), |
| 74 | + text_size=(s(config.TEXT_SIZE_WIDTH), None), |
| 75 | + top=(image.bottom - s(10))) |
| 76 | + |
| 77 | + # image == None for first and last slides (instructions and reminder) |
| 78 | + with If(texts[doc]['image'] == None): |
| 79 | + Label(text=texts[doc]['text'] + '\n\nYou may press the button in the' |
| 80 | + ' lower right corner to skip the practice', |
19 | 81 | text_size=(s(config.TEXT_SIZE_WIDTH), None), |
20 | | - top=self.exp.screen.center_y + s(415)) |
21 | | - |
22 | | - # image != None for 4 example slides |
23 | | - with If(texts[doc]['image'] != None): |
24 | | - image = Image(source=texts[doc]['image'], |
25 | | - top=(title.bottom - s(10)), |
26 | | - width=s(config.INST_IMG_WIDTH), |
27 | | - height=s(config.INST_IMG_HEIGHT), |
28 | | - allow_stretch=True, keep_ratio=False) |
29 | | - with If(texts[doc]['image'] != None): |
30 | | - Label(text=texts[doc]['text'], |
31 | | - font_size=s(config.INST_FONT_SIZE), |
32 | | - text_size=(s(config.TEXT_SIZE_WIDTH), None), |
33 | | - top=(image.bottom - s(10))) |
34 | | - |
35 | | - # image == None for first and last slides (instructions and reminder) |
36 | | - with If(texts[doc]['image'] == None): |
37 | | - Label(text=texts[doc]['text'], |
38 | | - text_size=(s(config.TEXT_SIZE_WIDTH), None), |
39 | | - font_size=s(config.INST_FONT_SIZE), |
40 | | - top=(title.bottom - s(10))) |
41 | | - |
42 | | - with UntilDone(): |
43 | | - Wait(1.0) |
44 | | - GetResponse(keys=texts[doc]['keys']) |
45 | | - |
46 | | - #RstDocument(text=texts[doc]['text'], |
47 | | - #width=self.exp.screen.height, |
48 | | - #height=self.exp.screen.height, |
49 | | - #base_font_size=s(config.RST_FONT_SIZE)) |
50 | | - |
51 | | - |
52 | | - with Serial(blocking=False): |
53 | | - with ButtonPress(): |
54 | | - Button(text="Skip Practice", right=self.exp.screen.width, |
55 | | - bottom=0, width=s(config.SKIP_SIZE[0]), |
56 | | - height=s(config.SKIP_SIZE[1]), blocking=False, |
57 | | - font_size=s(config.SKIP_FONT_SIZE)) |
| 82 | + font_size=s(config.INST_FONT_SIZE), |
| 83 | + top=(title.bottom - s(10))) |
| 84 | + |
| 85 | + with UntilDone(): |
| 86 | + Wait(1.0) |
| 87 | + GetResponse(keys=texts[doc]['keys']) |
| 88 | + |
| 89 | + #RstDocument(text=texts[doc]['text'], |
| 90 | + #width=self.exp.screen.height, |
| 91 | + #height=self.exp.screen.height, |
| 92 | + #base_font_size=s(config.RST_FONT_SIZE)) |
| 93 | + |
| 94 | + with Serial(blocking=False): |
| 95 | + with ButtonPress(): |
| 96 | + Button(text="Skip Practice", right=self.exp.screen.width, |
| 97 | + bottom=0, width=s(config.SKIP_SIZE[0]), |
| 98 | + height=s(config.SKIP_SIZE[1]), blocking=False, |
| 99 | + font_size=s(config.SKIP_FONT_SIZE)) |
| 100 | + |
58 | 101 | Wait(2.0) |
59 | 102 |
|
60 | 103 |
|
|
0 commit comments