psychopy 2024.2.1__py3-none-any.whl → 2024.2.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of psychopy might be problematic. Click here for more details.

Files changed (276) hide show
  1. psychopy/.DS_Store +0 -0
  2. psychopy/GIT_SHA +1 -1
  3. psychopy/VERSION +1 -1
  4. psychopy/__init__.py +10 -1
  5. psychopy/__init__.py.orig +65 -0
  6. psychopy/app/{locale/ar_001/.DS_Store → .DS_Store} +0 -0
  7. psychopy/app/Resources/.DS_Store +0 -0
  8. psychopy/app/_psychopyApp.py +11 -3
  9. psychopy/app/appData.spec +1 -1
  10. psychopy/app/builder/builder.py +1 -1
  11. psychopy/app/builder/builder.py.orig +3932 -0
  12. psychopy/app/builder/dialogs/__init__.py.orig +1679 -0
  13. psychopy/app/builder/dialogs/paramCtrls.py +1 -1
  14. psychopy/app/builder/dialogs/paramCtrls.py.orig +713 -0
  15. psychopy/app/colorpicker/__init__.py.orig +411 -0
  16. psychopy/app/cortex.log +0 -0
  17. psychopy/app/jobs.py +8 -1
  18. psychopy/app/locale/ar_001/LC_MESSAGE/messages.po +2452 -1731
  19. psychopy/app/locale/zh_CN/LC_MESSAGE/zh_CN.mo +0 -0
  20. psychopy/app/locale/zh_CN/LC_MESSAGE/zh_CN.po +6127 -0
  21. psychopy/app/locale/zh_CN/LC_MESSAGE/zh_CN_allFlagged.mo +0 -0
  22. psychopy/app/locale/zh_CN/LC_MESSAGE/zh_CN_allFlagged.po +7366 -0
  23. psychopy/app/plugin_manager/dialog.py +9 -7
  24. psychopy/app/ribbon.py +2 -1
  25. psychopy/app/runner/runner.py +7 -5
  26. psychopy/clock.py +8 -4
  27. psychopy/core.py.orig +169 -0
  28. psychopy/demos/builder/Design Templates/randomisedBlocks/html/index.html +23 -0
  29. psychopy/demos/builder/Design Templates/randomisedBlocks/html/randomisedBlocks-legacy-browsers.js +423 -0
  30. psychopy/demos/builder/Design Templates/randomisedBlocks/html/randomisedBlocks.js +427 -0
  31. psychopy/demos/builder/Design Templates/randomisedBlocks/html/resources/chooseBlock.xlsx +0 -0
  32. psychopy/demos/builder/Design Templates/randomisedBlocks/html/resources/facesBlock.xlsx +0 -0
  33. psychopy/demos/builder/Design Templates/randomisedBlocks/html/resources/housesBlock.xlsx +0 -0
  34. psychopy/demos/builder/Design Templates/randomisedBlocks/html/resources/stims/face01.jpg +0 -0
  35. psychopy/demos/builder/Design Templates/randomisedBlocks/html/resources/stims/face02.jpg +0 -0
  36. psychopy/demos/builder/Design Templates/randomisedBlocks/html/resources/stims/face03.jpg +0 -0
  37. psychopy/demos/builder/Design Templates/randomisedBlocks/html/resources/stims/house01.jpg +0 -0
  38. psychopy/demos/builder/Design Templates/randomisedBlocks/html/resources/stims/house02.jpg +0 -0
  39. psychopy/demos/builder/Design Templates/randomisedBlocks/html/resources/stims/house03.jpg +0 -0
  40. psychopy/demos/builder/Design Templates/randomisedBlocks/randomisedBlocks.py +330 -0
  41. psychopy/demos/builder/Design Templates/randomisedBlocks/randomisedBlocks_lastrun.py +330 -0
  42. psychopy/demos/builder/Feature Demos/eyetracking/eyetracking.xml +298 -0
  43. psychopy/demos/builder/Feature Demos/eyetracking/eyetracking.xsd +120 -0
  44. psychopy/demos/builder/Tools/.DS_Store +0 -0
  45. psychopy/demos/builder/Tools/gammaCalibration/.DS_Store +0 -0
  46. psychopy/demos/builder/Tools/gammaCalibration/data/_gamma_correction_visual_2022-05-18_14h18.29.439.csv +38 -0
  47. psychopy/demos/builder/Tools/gammaCalibration/data/_gamma_correction_visual_2022-05-18_14h18.29.439.log +3418 -0
  48. psychopy/demos/builder/Tools/gammaCalibration/data/_gamma_correction_visual_2022-05-18_14h18.29.439.psydat +0 -0
  49. psychopy/demos/builder/Tools/gammaCalibration/data/x1_gamma_correction_visual_2022-05-17_13h59.42.928.csv +2 -0
  50. psychopy/demos/builder/Tools/gammaCalibration/data/x1_gamma_correction_visual_2022-05-17_13h59.42.928.log +15 -0
  51. psychopy/demos/builder/Tools/gammaCalibration/data/x1_gamma_correction_visual_2022-05-17_13h59.42.928.psydat +0 -0
  52. psychopy/demos/builder/Tools/gammaCalibration/gamma_correction_visual.psyexp +323 -0
  53. psychopy/demos/builder/Tools/gammaCalibration/gamma_correction_visual.py +562 -0
  54. psychopy/demos/builder/Tools/gammaCalibration/gamma_correction_visual_lastrun.py +562 -0
  55. psychopy/demos/builder/Tools/gammaCalibration/questStairs.xlsx +0 -0
  56. psychopy/demos/builder/Tools/gammaCalibration/readme.md +0 -0
  57. psychopy/demos/builder/Tools/gammaCalibration/resources/low_contrast.png +0 -0
  58. psychopy/demos/builder/Tools/gammaCalibration/resources/make_2nd_order_tex.py +59 -0
  59. psychopy/demos/builder/Tools/gammaCalibration/resources/second_order_tex.png +0 -0
  60. psychopy/demos/coder/.DS_Store +0 -0
  61. psychopy/demos/coder/experiment control/info_gamma.pickle +0 -0
  62. psychopy/demos/coder/iohub/.iohpid +1 -0
  63. psychopy/demos/coder/iohub/eyetracking/.iohpid +1 -0
  64. psychopy/demos/coder/iohub/wintab/.DS_Store +0 -0
  65. psychopy/demos/coder/stimuli/.DS_Store +0 -0
  66. psychopy/demos/coder/stimuli/radialGratingContracting.py +29 -0
  67. psychopy/experiment/_experiment.py.orig +1032 -0
  68. psychopy/experiment/components/.DS_Store +0 -0
  69. psychopy/experiment/components/_base.py +13 -4
  70. psychopy/experiment/components/_base.py.orig +823 -0
  71. psychopy/experiment/components/form/.DS_Store +0 -0
  72. psychopy/experiment/components/microphone/__init__.py +10 -1
  73. psychopy/experiment/components/microphone/__init__.py.orig +490 -0
  74. psychopy/experiment/components/polygon/__init__.py +21 -22
  75. psychopy/experiment/components/settings/__init__.py +13 -14
  76. psychopy/experiment/components/settings/__init__.py.orig +1337 -0
  77. psychopy/experiment/components/textbox/__init__.py.orig +310 -0
  78. psychopy/experiment/components/webcam/.DS_Store +0 -0
  79. psychopy/experiment/components/webcam/light/.DS_Store +0 -0
  80. psychopy/experiment/flow.py +10 -8
  81. psychopy/experiment/loops.py.orig +829 -0
  82. psychopy/experiment/params.py +8 -3
  83. psychopy/experiment/params.py.orig +408 -0
  84. psychopy/experiment/routine.py.orig +503 -0
  85. psychopy/experiment/routines/_base.py +15 -6
  86. psychopy/experiment/routines/counterbalance/__init__.py +1 -0
  87. psychopy/gui/qtgui.py +14 -7
  88. psychopy/gui/util.py +10 -14
  89. psychopy/gui/wxgui.py +10 -4
  90. psychopy/hardware/.DS_Store +0 -0
  91. psychopy/hardware/brainproducts.py.orig +680 -0
  92. psychopy/hardware/iolab.py.orig +238 -0
  93. psychopy/hardware/manager.py +1 -1
  94. psychopy/hardware/photodiode.py +59 -27
  95. psychopy/hardware/serialport.py +51 -0
  96. psychopy/hardware/speaker.py +4 -4
  97. psychopy/iohub/datastore/__init__.py.orig +443 -0
  98. psychopy/iohub/datastore/util.py.orig +692 -0
  99. psychopy/iohub/devices/mouse/darwin.py.orig +427 -0
  100. psychopy/iohub/devices/mouse/linux2.py.orig +198 -0
  101. psychopy/preferences/.DS_Store +0 -0
  102. psychopy/projects/pavlovia.py +10 -3
  103. psychopy/projects/pavlovia.py.orig +1295 -0
  104. psychopy/sound/backend_ptb.py +22 -5
  105. psychopy/sound/transcribe.py +24 -4
  106. psychopy/tests/.DS_Store +0 -0
  107. psychopy/tests/data/.DS_Store +0 -0
  108. psychopy/tests/data/TestCircle_fill_local.png +0 -0
  109. psychopy/tests/data/__test.png +0 -0
  110. psychopy/tests/data/aperture1_normHexbackground_local.png +0 -0
  111. psychopy/tests/data/aperture1_norm_local.png +0 -0
  112. psychopy/tests/data/aperture2_normHexbackground_local.png +0 -0
  113. psychopy/tests/data/beatandrcos_height_local.png +0 -0
  114. psychopy/tests/data/beatandrcos_normAddBlend_local.png +0 -0
  115. psychopy/tests/data/beatandrcos_normHexbackground_local.png +0 -0
  116. psychopy/tests/data/beatandrcos_norm_local.png +0 -0
  117. psychopy/tests/data/beatandrcos_stencil_local.png +0 -0
  118. psychopy/tests/data/blend_add_height_local.png +0 -0
  119. psychopy/tests/data/blend_add_normAddBlend_local.png +0 -0
  120. psychopy/tests/data/blend_add_normHexbackground_local.png +0 -0
  121. psychopy/tests/data/blend_add_normNoShade_local.png +0 -0
  122. psychopy/tests/data/blend_add_norm_local.png +0 -0
  123. psychopy/tests/data/blend_add_stencil_local.png +0 -0
  124. psychopy/tests/data/bufferimg_gabor_height_local.png +0 -0
  125. psychopy/tests/data/bufferimg_gabor_normAddBlend_local.png +0 -0
  126. psychopy/tests/data/bufferimg_gabor_normHexbackground_local.png +0 -0
  127. psychopy/tests/data/bufferimg_gabor_normNoShade_local.png +0 -0
  128. psychopy/tests/data/bufferimg_gabor_norm_local.png +0 -0
  129. psychopy/tests/data/bufferimg_gabor_stencil_local.png +0 -0
  130. psychopy/tests/data/circleHex_height_local.png +0 -0
  131. psychopy/tests/data/circleHex_normAddBlend_local.png +0 -0
  132. psychopy/tests/data/circleHex_normHexbackground_local.png +0 -0
  133. psychopy/tests/data/circleHex_normNoShade_local.png +0 -0
  134. psychopy/tests/data/circleHex_norm_local.png +0 -0
  135. psychopy/tests/data/circleHex_stencil_local.png +0 -0
  136. psychopy/tests/data/color_comparison_local.png +0 -0
  137. psychopy/tests/data/corrFullRandom_local.csv +16 -0
  138. psychopy/tests/data/corrFullRandom_local.tsv +6 -0
  139. psychopy/tests/data/correctScript/.DS_Store +0 -0
  140. psychopy/tests/data/dots_height_local.png +0 -0
  141. psychopy/tests/data/dots_normAddBlend_local.png +0 -0
  142. psychopy/tests/data/dots_normHexbackground_local.png +0 -0
  143. psychopy/tests/data/dots_normNoShade_local.png +0 -0
  144. psychopy/tests/data/dots_norm_local.png +0 -0
  145. psychopy/tests/data/dots_stencil_local.png +0 -0
  146. psychopy/tests/data/elarray1_height_local.png +0 -0
  147. psychopy/tests/data/elarray1_normAddBlend_local.png +0 -0
  148. psychopy/tests/data/elarray1_normHexbackground_local.png +0 -0
  149. psychopy/tests/data/elarray1_norm_local.png +0 -0
  150. psychopy/tests/data/elarray1_stencil_local.png +0 -0
  151. psychopy/tests/data/envelopeandrcos_height_local.png +0 -0
  152. psychopy/tests/data/envelopeandrcos_normAddBlend_local.png +0 -0
  153. psychopy/tests/data/envelopeandrcos_normHexbackground_local.png +0 -0
  154. psychopy/tests/data/envelopeandrcos_norm_local.png +0 -0
  155. psychopy/tests/data/envelopeandrcos_stencil_local.png +0 -0
  156. psychopy/tests/data/envelopepowerandrcos_height_local.png +0 -0
  157. psychopy/tests/data/envelopepowerandrcos_normAddBlend_local.png +0 -0
  158. psychopy/tests/data/envelopepowerandrcos_normHexbackground_local.png +0 -0
  159. psychopy/tests/data/envelopepowerandrcos_norm_local.png +0 -0
  160. psychopy/tests/data/envelopepowerandrcos_stencil_local.png +0 -0
  161. psychopy/tests/data/gabor1_height_local.png +0 -0
  162. psychopy/tests/data/gabor1_normAddBlend_local.png +0 -0
  163. psychopy/tests/data/gabor1_normHexbackground_local.png +0 -0
  164. psychopy/tests/data/gabor1_normNoShade_local.png +0 -0
  165. psychopy/tests/data/gabor1_norm_local.png +0 -0
  166. psychopy/tests/data/gabor1_stencil_local.png +0 -0
  167. psychopy/tests/data/greyscale_normHexbackground_local.png +0 -0
  168. psychopy/tests/data/imageAndGauss_height_local.png +0 -0
  169. psychopy/tests/data/imageAndGauss_normAddBlend_local.png +0 -0
  170. psychopy/tests/data/imageAndGauss_normHexbackground_local.png +0 -0
  171. psychopy/tests/data/imageAndGauss_normNoShade_local.png +0 -0
  172. psychopy/tests/data/imageAndGauss_norm_local.png +0 -0
  173. psychopy/tests/data/imageAndGauss_stencil_local.png +0 -0
  174. psychopy/tests/data/movFrame1_stencil_local.png +0 -0
  175. psychopy/tests/data/noiseAndRcos_height_local.png +0 -0
  176. psychopy/tests/data/noiseAndRcos_normAddBlend_local.png +0 -0
  177. psychopy/tests/data/noiseAndRcos_normHexbackground_local.png +0 -0
  178. psychopy/tests/data/noiseAndRcos_normNoShade_local.png +0 -0
  179. psychopy/tests/data/noiseAndRcos_norm_local.png +0 -0
  180. psychopy/tests/data/noiseAndRcos_stencil_local.png +0 -0
  181. psychopy/tests/data/noiseFiltersAndRcos_height_local.png +0 -0
  182. psychopy/tests/data/noiseFiltersAndRcos_normAddBlend_local.png +0 -0
  183. psychopy/tests/data/noiseFiltersAndRcos_normHexbackground_local.png +0 -0
  184. psychopy/tests/data/noiseFiltersAndRcos_normNoShade_local.png +0 -0
  185. psychopy/tests/data/noiseFiltersAndRcos_norm_local.png +0 -0
  186. psychopy/tests/data/noiseFiltersAndRcos_stencil_local.png +0 -0
  187. psychopy/tests/data/numpyImage_height_local.png +0 -0
  188. psychopy/tests/data/numpyImage_normAddBlend_local.png +0 -0
  189. psychopy/tests/data/numpyImage_normHexbackground_local.png +0 -0
  190. psychopy/tests/data/numpyImage_normNoShade_local.png +0 -0
  191. psychopy/tests/data/numpyImage_norm_local.png +0 -0
  192. psychopy/tests/data/numpyImage_stencil_local.png +0 -0
  193. psychopy/tests/data/shape2_1_normAddBlend_local.png +0 -0
  194. psychopy/tests/data/shape2_1_normHexbackground_local.png +0 -0
  195. psychopy/tests/data/shape2_1_normNoShade_local.png +0 -0
  196. psychopy/tests/data/shape2_1_norm_local.png +0 -0
  197. psychopy/tests/data/shape2_1_stencil_local.png +0 -0
  198. psychopy/tests/data/testLoopsBlocks.psyexp_local.py +328 -0
  199. psychopy/tests/data/text1_height_local.png +0 -0
  200. psychopy/tests/data/text1_normAddBlend_local.png +0 -0
  201. psychopy/tests/data/text1_normHexbackground_local.png +0 -0
  202. psychopy/tests/data/text1_norm_local.png +0 -0
  203. psychopy/tests/data/text1_stencil_local.png +0 -0
  204. psychopy/tests/data/text2_height.png +0 -0
  205. psychopy/tests/data/text2_normAddBlend.png +0 -0
  206. psychopy/tests/data/text2_normHexbackground.png +0 -0
  207. psychopy/tests/data/text2_stencil.png +0 -0
  208. psychopy/tests/data/wedge1_height_local.png +0 -0
  209. psychopy/tests/data/wedge1_normAddBlend_local.png +0 -0
  210. psychopy/tests/data/wedge1_normHexbackground_local.png +0 -0
  211. psychopy/tests/data/wedge1_normNoShade_local.png +0 -0
  212. psychopy/tests/data/wedge1_norm_local.png +0 -0
  213. psychopy/tests/data/wedge1_stencil_local.png +0 -0
  214. psychopy/tests/test_app/.DS_Store +0 -0
  215. psychopy/tests/test_app/test_builder/.DS_Store +0 -0
  216. psychopy/tests/test_app/test_builder/data/_2021_ 5_03_1206.csv +9 -0
  217. psychopy/tests/test_app/test_builder/data/_2021_ 5_03_1206.log +177 -0
  218. psychopy/tests/test_app/test_builder/data/_2021_ 5_03_1206.psydat +0 -0
  219. psychopy/tests/test_app/test_builder/data/_2021_ 5_03_1206.xlsx +0 -0
  220. psychopy/tests/test_app/test_builder/data/_2021_ 5_03_1324.csv +9 -0
  221. psychopy/tests/test_app/test_builder/data/_2021_ 5_03_1324.log +168 -0
  222. psychopy/tests/test_app/test_builder/data/_2021_ 5_03_1324.psydat +0 -0
  223. psychopy/tests/test_app/test_builder/data/_2021_ 5_03_1324.xlsx +0 -0
  224. psychopy/tests/test_data/.DS_Store +0 -0
  225. psychopy/tests/test_hardware/test_CRS_BitsSharp.py.orig +68 -0
  226. psychopy/tests/test_tools/test_arraytools.py +112 -0
  227. psychopy/tests/test_visual/test_image.py.orig +219 -0
  228. psychopy/tools/arraytools.py +47 -0
  229. psychopy/tools/versionchooser.py +1 -1
  230. psychopy/visual/backends/pygletbackend.py +26 -8
  231. psychopy/visual/basevisual.py.orig +1723 -0
  232. psychopy/visual/form.py.orig +1181 -0
  233. psychopy/visual/text.py.orig +752 -0
  234. psychopy/visual/textbox2/textbox2.py.orig +1315 -0
  235. psychopy/visual/window.py +13 -5
  236. psychopy/visual/windowwarp.py.orig +463 -0
  237. {psychopy-2024.2.1.dist-info → psychopy-2024.2.4.dist-info}/METADATA +9 -9
  238. {psychopy-2024.2.1.dist-info → psychopy-2024.2.4.dist-info}/RECORD +244 -78
  239. {psychopy-2024.2.1.dist-info → psychopy-2024.2.4.dist-info}/WHEEL +1 -1
  240. {psychopy-2024.2.1.dist-info → psychopy-2024.2.4.dist-info}/entry_points.txt +2 -0
  241. psychopy/app/locale/ar_001/LC_MESSAGE/messages.mo +0 -0
  242. psychopy/app/locale/cs_CZ/LC_MESSAGE/messages.mo +0 -0
  243. psychopy/app/locale/da_DK/LC_MESSAGE/messages.mo +0 -0
  244. psychopy/app/locale/de_DE/LC_MESSAGE/messages.mo +0 -0
  245. psychopy/app/locale/el_GR/LC_MESSAGE/messages.mo +0 -0
  246. psychopy/app/locale/en_NZ/LC_MESSAGE/messages.mo +0 -0
  247. psychopy/app/locale/en_US/LC_MESSAGE/messages.mo +0 -0
  248. psychopy/app/locale/es_CO/LC_MESSAGE/messages.mo +0 -0
  249. psychopy/app/locale/es_ES/LC_MESSAGE/messages.mo +0 -0
  250. psychopy/app/locale/es_US/LC_MESSAGE/messages.mo +0 -0
  251. psychopy/app/locale/et_EE/LC_MESSAGE/messages.mo +0 -0
  252. psychopy/app/locale/fa_IR/LC_MESSAGE/messages.mo +0 -0
  253. psychopy/app/locale/fi_FI/LC_MESSAGE/messages.mo +0 -0
  254. psychopy/app/locale/fr_FR/LC_MESSAGE/messages.mo +0 -0
  255. psychopy/app/locale/he_IL/LC_MESSAGE/messages.mo +0 -0
  256. psychopy/app/locale/hi_IN/LC_MESSAGE/messages.mo +0 -0
  257. psychopy/app/locale/hu_HU/LC_MESSAGE/messages.mo +0 -0
  258. psychopy/app/locale/it_IT/LC_MESSAGE/messages.mo +0 -0
  259. psychopy/app/locale/ja_JP/LC_MESSAGE/messages.mo +0 -0
  260. psychopy/app/locale/ko_KR/LC_MESSAGE/messages.mo +0 -0
  261. psychopy/app/locale/ms_MY/LC_MESSAGE/messages.mo +0 -0
  262. psychopy/app/locale/nl_NL/LC_MESSAGE/messages.mo +0 -0
  263. psychopy/app/locale/nn_NO/LC_MESSAGE/messages.mo +0 -0
  264. psychopy/app/locale/pl_PL/LC_MESSAGE/messages.mo +0 -0
  265. psychopy/app/locale/pt_PT/LC_MESSAGE/messages.mo +0 -0
  266. psychopy/app/locale/ro_RO/LC_MESSAGE/messages.mo +0 -0
  267. psychopy/app/locale/ru_RU/LC_MESSAGE/messages.mo +0 -0
  268. psychopy/app/locale/sv_SE/LC_MESSAGE/messages.mo +0 -0
  269. psychopy/app/locale/tr_TR/LC_MESSAGE/messages.mo +0 -0
  270. psychopy/app/locale/zh_CN/LC_MESSAGE/messages.mo +0 -0
  271. psychopy/app/locale/zh_TW/LC_MESSAGE/messages.mo +0 -0
  272. psychopy-2024.2.1.dist-info/licenses/AUTHORS.md +0 -138
  273. /psychopy/{app/locale/ar_001/LC_MESSAGE → demos/builder}/.DS_Store +0 -0
  274. /psychopy/{app/locale/es_ES/LC_MESSAGE → demos/builder/Experiments}/.DS_Store +0 -0
  275. /psychopy/{visual → demos/builder/Tools/gammaCalibration/data}/.DS_Store +0 -0
  276. {psychopy-2024.2.1.dist-info → psychopy-2024.2.4.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,310 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ # Part of the PsychoPy library
5
+ # Copyright (C) 2002-2018 Jonathan Peirce (C) 2019-2021 Open Science Tools Ltd.
6
+ # Distributed under the terms of the GNU General Public License (GPL).
7
+
8
+ from __future__ import absolute_import, print_function
9
+
10
+ from os import path
11
+ from pathlib import Path
12
+ import copy
13
+ from psychopy.alerts import alerttools, alert
14
+ from psychopy.experiment.components import BaseVisualComponent, Param, getInitVals, _translate
15
+ from psychopy.localization import _localized as __localized
16
+ from ..keyboard import KeyboardComponent
17
+ _localized = __localized.copy()
18
+
19
+ # only use _localized values for label values, nothing functional:
20
+ _localized.update({'text': _translate('Text'),
21
+ 'font': _translate('Font'),
22
+ 'letterHeight': _translate('Letter height'),
23
+ 'flipHorizontal': _translate('Flip horizontal'),
24
+ 'flipVertical': _translate('Flip vertical'),
25
+ 'languageStyle': _translate('Language style'),
26
+ 'bold': _translate('Bold'),
27
+ 'italic': _translate('Italic'),
28
+ 'lineSpacing': _translate('Line Spacing'),
29
+ 'padding': _translate('Padding'),
30
+ 'anchor': _translate('Anchor'),
31
+ 'fillColor': _translate('Fill Colour'),
32
+ 'borderColor': _translate('Border Colour'),
33
+ 'borderWidth': _translate('Border Width'),
34
+ 'editable': _translate('Editable?'),
35
+ 'autoLog': _translate('Auto Log')
36
+ })
37
+
38
+
39
+ class TextboxComponent(BaseVisualComponent):
40
+ """An event class for presenting text-based stimuli
41
+ """
42
+ categories = ['Stimuli', 'Responses']
43
+ targets = ['PsychoPy', 'PsychoJS']
44
+ iconFile = Path(__file__).parent / 'textbox.png'
45
+ tooltip = _translate('Textbox: present text stimuli but cooler')
46
+ beta = True
47
+
48
+ def __init__(self, exp, parentName, name='textbox',
49
+ # effectively just a display-value
50
+ text=_translate('Any text\n\nincluding line breaks'),
51
+ font='Open Sans', units='from exp settings', bold=False, italic=False,
52
+ color='white', colorSpace='rgb', opacity="",
53
+ pos=(0, 0), size=(None, None), letterHeight=0.05, ori=0,
54
+ lineSpacing=1.0, padding=0, # gap between box and text
55
+ startType='time (s)', startVal=0.0, anchor='center',
56
+ stopType='duration (s)', stopVal=1.0,
57
+ startEstim='', durationEstim='',
58
+ languageStyle='LTR', fillColor="None",
59
+ borderColor="None", borderWidth=2,
60
+ flipHoriz=False,
61
+ flipVert=False,
62
+ editable=False, autoLog=True):
63
+ super(TextboxComponent, self).__init__(exp, parentName, name,
64
+ units=units,
65
+ color=color, fillColor=fillColor, borderColor=borderColor,
66
+ colorSpace=colorSpace,
67
+ pos=pos,
68
+ ori=ori,
69
+ size=size,
70
+ startType=startType,
71
+ startVal=startVal,
72
+ stopType=stopType,
73
+ stopVal=stopVal,
74
+ startEstim=startEstim,
75
+ durationEstim=durationEstim)
76
+ self.type = 'Textbox'
77
+ self.url = "https://www.psychopy.org/builder/components/textbox.html"
78
+ self.order += [ # controls order of params within tabs
79
+ "editable", "text", # Basic tab
80
+ "borderWidth", "opacity", # Appearance tab
81
+ "font", "letterHeight", "lineSpacing", "bold", "italic", # Formatting tab
82
+ ]
83
+ self.order.insert(self.order.index("units"), "padding") # Add "padding" just before spatial units
84
+ # params
85
+ _allow3 = ['constant', 'set every repeat', 'set every frame'] # list
86
+ self.params['color'].label = _translate("Text Color")
87
+
88
+ self.params['text'] = Param(
89
+ text, valType='str', inputType="multi", allowedTypes=[], categ='Basic',
90
+ updates='constant', allowedUpdates=_allow3[:], # copy the list
91
+ hint=_translate("The text to be displayed"),
92
+ label=_localized['text'])
93
+ self.params['font'] = Param(
94
+ font, valType='str', inputType="single", allowedTypes=[], categ='Formatting',
95
+ updates='constant', allowedUpdates=_allow3[:], # copy the list
96
+ hint=_translate("The font name (e.g. Comic Sans)"),
97
+ label=_localized['font'])
98
+ self.params['letterHeight'] = Param(
99
+ letterHeight, valType='num', inputType="single", allowedTypes=[], categ='Formatting',
100
+ updates='constant', allowedUpdates=_allow3[:], # copy the list
101
+ hint=_translate("Specifies the height of the letter (the width"
102
+ " is then determined by the font)"),
103
+ label=_localized['letterHeight'])
104
+ self.params['flipHoriz'] = Param(
105
+ flipHoriz, valType='bool', inputType="bool", allowedTypes=[], categ='Layout',
106
+ updates='constant',
107
+ hint=_translate("horiz = left-right reversed; vert = up-down"
108
+ " reversed; $var = variable"),
109
+ label=_localized['flipHorizontal'])
110
+ self.params['flipVert'] = Param(
111
+ flipVert, valType='bool', inputType="bool", allowedTypes=[], categ='Layout',
112
+ updates='constant',
113
+ hint=_translate("horiz = left-right reversed; vert = up-down"
114
+ " reversed; $var = variable"),
115
+ label=_localized['flipVertical'])
116
+ self.params['languageStyle'] = Param(
117
+ languageStyle, valType='str', inputType="choice", categ='Formatting',
118
+ allowedVals=['LTR', 'RTL', 'Arabic'],
119
+ hint=_translate("Handle right-to-left (RTL) languages and Arabic reshaping"),
120
+ label=_localized['languageStyle'])
121
+ self.params['italic'] = Param(
122
+ italic, valType='bool', inputType="bool", allowedTypes=[], categ='Formatting',
123
+ updates='constant',
124
+ hint=_translate("Should text be italic?"),
125
+ label=_localized['italic'])
126
+ self.params['bold'] = Param(
127
+ bold, valType='bool', inputType="bool", allowedTypes=[], categ='Formatting',
128
+ updates='constant',
129
+ hint=_translate("Should text be bold?"),
130
+ label=_localized['bold'])
131
+ self.params['lineSpacing'] = Param(
132
+ lineSpacing, valType='num', inputType="single", allowedTypes=[], categ='Formatting',
133
+ updates='constant',
134
+ hint=_translate("Defines the space between lines"),
135
+ label=_localized['lineSpacing'])
136
+ self.params['padding'] = Param(
137
+ padding, valType='num', inputType="single", allowedTypes=[], categ='Layout',
138
+ updates='constant', allowedUpdates=_allow3[:],
139
+ hint=_translate("Defines the space between text and the textbox border"),
140
+ label=_localized['padding'])
141
+ self.params['anchor'] = Param(
142
+ anchor, valType='str', inputType="choice", categ='Layout',
143
+ allowedVals=['center',
144
+ 'top-center',
145
+ 'bottom-center',
146
+ 'center-left',
147
+ 'center-right',
148
+ 'top-left',
149
+ 'top-right',
150
+ 'bottom-left',
151
+ 'bottom-right',
152
+ ],
153
+ updates='constant',
154
+ hint=_translate("Should text anchor to the top, center or bottom of the box?"),
155
+ label=_localized['anchor'])
156
+ self.params['borderWidth'] = Param(
157
+ borderWidth, valType='num', inputType="single", allowedTypes=[], categ='Appearance',
158
+ updates='constant', allowedUpdates=_allow3[:],
159
+ hint=_translate("Textbox border width"),
160
+ label=_localized['borderWidth'])
161
+ self.params['editable'] = Param(
162
+ editable, valType='bool', inputType="bool", allowedTypes=[], categ='Basic',
163
+ updates='constant',
164
+ hint=_translate("Should textbox be editable?"),
165
+ label=_localized['editable'])
166
+ self.params['autoLog'] = Param(
167
+ autoLog, valType='bool', inputType="bool", allowedTypes=[], categ='Data',
168
+ updates='constant',
169
+ hint=_translate(
170
+ 'Automatically record all changes to this in the log file'),
171
+ label=_localized['autoLog'])
172
+
173
+ def writeInitCode(self, buff):
174
+ # do we need units code?
175
+ if self.params['units'].val == 'from exp settings':
176
+ unitsStr = ""
177
+ else:
178
+ unitsStr = "units=%(units)s," % self.params
179
+ # do writing of init
180
+ # replaces variable params with sensible defaults
181
+ inits = getInitVals(self.params, 'PsychoPy')
182
+ code = (
183
+ "%(name)s = visual.TextBox2(\n"
184
+ " win, text=%(text)s, font=%(font)s,\n"
185
+ " pos=%(pos)s," + unitsStr +
186
+ " letterHeight=%(letterHeight)s,\n"
187
+ " size=%(size)s, borderWidth=%(borderWidth)s,\n"
188
+ " color=%(color)s, colorSpace=%(colorSpace)s,\n"
189
+ " opacity=%(opacity)s,\n"
190
+ " bold=%(bold)s, italic=%(italic)s,\n"
191
+ " lineSpacing=%(lineSpacing)s,\n"
192
+ " padding=%(padding)s,\n"
193
+ " anchor=%(anchor)s,\n"
194
+ " fillColor=%(fillColor)s, borderColor=%(borderColor)s,\n"
195
+ " flipHoriz=%(flipHoriz)s, flipVert=%(flipVert)s,\n"
196
+ " editable=%(editable)s,\n"
197
+ " name='%(name)s',\n"
198
+ " autoLog=%(autoLog)s,\n"
199
+ ")\n"
200
+ )
201
+ buff.writeIndentedLines(code % inits)
202
+
203
+ def writeInitCodeJS(self, buff):
204
+ # do we need units code?
205
+ if self.params['units'].val == 'from exp settings':
206
+ unitsStr = " units: undefined, \n"
207
+ else:
208
+ unitsStr = " units: %(units)s, \n" % self.params
209
+ # do writing of init
210
+ # replaces variable params with sensible defaults
211
+ inits = getInitVals(self.params, 'PsychoJS')
212
+
213
+ # check for NoneTypes
214
+ for param in inits:
215
+ if inits[param] in [None, 'None', '']:
216
+ inits[param].val = 'undefined'
217
+ if param == 'text':
218
+ inits[param].val = ""
219
+
220
+ code = ("%(name)s = new visual.TextBox({\n"
221
+ " win: psychoJS.window,\n"
222
+ " name: '%(name)s',\n"
223
+ " text: %(text)s,\n"
224
+ " font: %(font)s,\n"
225
+ " pos: %(pos)s, letterHeight: %(letterHeight)s,\n"
226
+ " size: %(size)s," + unitsStr +
227
+ " color: %(color)s, colorSpace: %(colorSpace)s,\n"
228
+ " fillColor: %(fillColor)s, borderColor: %(borderColor)s,\n"
229
+ " bold: %(bold)s, italic: %(italic)s,\n"
230
+ " opacity: %(opacity)s,\n"
231
+ " padding: %(padding)s,\n"
232
+ " editable: %(editable)s,\n"
233
+ " multiline: true,\n"
234
+ " anchor: %(anchor)s,\n")
235
+ buff.writeIndentedLines(code % inits)
236
+
237
+ depth = -self.getPosInRoutine()
238
+ code = (" depth: %.1f \n"
239
+ "});\n\n" % (depth))
240
+ buff.writeIndentedLines(code)
241
+ depth = -self.getPosInRoutine()
242
+
243
+ def writeRoutineStartCode(self, buff):
244
+ # Give alert if in the same routine as a Keyboard component
245
+ if self.params['editable'].val:
246
+ routine = self.exp.routines[self.parentName]
247
+ for sibling in routine:
248
+ if isinstance(sibling, KeyboardComponent):
249
+ alert(4405, strFields={'textbox': self.params['name'], 'keyboard': sibling.params['name']})
250
+
251
+ code = (
252
+ "%(name)s.reset()"
253
+ )
254
+ buff.writeIndentedLines(code % self.params)
255
+ BaseVisualComponent.writeRoutineStartCode(self, buff)
256
+
257
+ def writeRoutineStartCodeJS(self, buff):
258
+ <<<<<<< HEAD
259
+ if self.params['editable']:
260
+ # replaces variable params with sensible defaults
261
+ inits = getInitVals(self.params, 'PsychoJS')
262
+ # check for NoneTypes
263
+ for param in inits:
264
+ if inits[param] in [None, 'None', '']:
265
+ inits[param].val = 'undefined'
266
+ if param == 'text':
267
+ inits[param].val = ""
268
+
269
+ code = (
270
+ "%(name)s.setText(%(text)s);"
271
+ )
272
+ buff.writeIndentedLines(code % inits)
273
+ =======
274
+ if self.params['text'].updates != 'constant':
275
+ # replaces variable params with sensible defaults
276
+ resetText = copy.copy(self.params['text'])
277
+ if resetText.val in [None, 'None']:
278
+ resetText.val = ""
279
+ code = (
280
+ "%(name)s.setText(%(text)s);"
281
+ )
282
+ buff.writeIndentedLines(code % self.params)
283
+ >>>>>>> 134cf4f6767c7410614bc288b766a962b1a927b6
284
+ BaseVisualComponent.writeRoutineStartCodeJS(self, buff)
285
+
286
+ def writeRoutineEndCode(self, buff):
287
+ name = self.params['name']
288
+ if len(self.exp.flow._loopList):
289
+ currLoop = self.exp.flow._loopList[-1] # last (outer-most) loop
290
+ else:
291
+ currLoop = self.exp._expHandler
292
+ if self.params['editable']:
293
+ buff.writeIndentedLines(f"{currLoop.params['name']}.addData('{name}.text',{name}.text)\n")
294
+ # get parent to write code too (e.g. store onset/offset times)
295
+ super().writeRoutineEndCode(buff)
296
+
297
+ def writeRoutineEndCodeJS(self, buff):
298
+ name = self.params['name']
299
+ if len(self.exp.flow._loopList):
300
+ currLoop = self.exp.flow._loopList[-1] # last (outer-most) loop
301
+ else:
302
+ currLoop = self.exp._expHandler
303
+ if self.params['editable']:
304
+ buff.writeIndentedLines(f"psychoJS.experiment.addData('{name}.text',{name}.text)\n")
305
+ # get parent to write code too (e.g. store onset/offset times)
306
+ super().writeRoutineEndCodeJS(buff)
307
+
308
+ def integrityCheck(self):
309
+ super().integrityCheck() # run parent class checks first
310
+ alerttools.testFont(self) # Test whether font is available locally
@@ -41,7 +41,7 @@ class Flow(list):
41
41
  loopStack = [currentList]
42
42
  for thisEntry in self:
43
43
  if thisEntry.getType() == 'LoopInitiator':
44
- currentList.append(thisEntry.loop) # this loop is child of current
44
+ currentList.append(thisEntry.loop) # this loop is child of current
45
45
  loopDict[thisEntry.loop] = [] # and is (current) empty list awaiting children
46
46
  currentList = loopDict[thisEntry.loop]
47
47
  loopStack.append(loopDict[thisEntry.loop]) # update the list of loops (for depth)
@@ -140,7 +140,6 @@ class Flow(list):
140
140
  # right-click in GUI)
141
141
  del self[id]
142
142
 
143
-
144
143
  def integrityCheck(self):
145
144
  """Check that the flow makes sense together and check each component"""
146
145
 
@@ -168,7 +167,7 @@ class Flow(list):
168
167
  if not hasattr(field, 'label'):
169
168
  continue # no problem, no warning
170
169
  if (field.label.lower() in ['text', 'customize'] or
171
- not field.valType in ('str', 'code')):
170
+ field.valType not in ('str', 'code')):
172
171
  continue
173
172
  if (isinstance(field.val, str) and
174
173
  field.val != field.val.strip()):
@@ -204,7 +203,7 @@ class Flow(list):
204
203
  # non-redundant, order unknown
205
204
  print('\n '.join(list(set(warnings))))
206
205
 
207
- def writePreCode(self,script):
206
+ def writePreCode(self, script):
208
207
  """Write the code that comes before the Window is created
209
208
  """
210
209
  script.writeIndentedLines("\n# Start Code - component code to be "
@@ -275,6 +274,8 @@ class Flow(list):
275
274
  code = (
276
275
  "# mark experiment as started\n"
277
276
  "thisExp.status = STARTED\n"
277
+ "# make sure window is set to foreground to prevent losing focus\n"
278
+ "win.winHandle.activate()\n"
278
279
  "# make sure variables created by exec are available globally\n"
279
280
  "exec = environmenttools.setExecEnvironment(globals())\n"
280
281
  "# get device handles from dict of input devices\n"
@@ -342,7 +343,7 @@ class Flow(list):
342
343
  "expInfo['expStart'] = data.getDateStr(\n"
343
344
  " format='%Y-%m-%d %Hh%M.%S.%f %z', fractionalSecondDigits=6\n"
344
345
  ")\n"
345
- )
346
+ )
346
347
  script.writeIndentedLines(code)
347
348
  # run-time code
348
349
  for entry in self:
@@ -401,13 +402,14 @@ class Flow(list):
401
402
  "\n"
402
403
  "const flowScheduler = new Scheduler(psychoJS);\n"
403
404
  "const dialogCancelScheduler = new Scheduler(psychoJS);\n"
404
- "psychoJS.scheduleCondition(function() { return (psychoJS.gui.dialogComponent.button === 'OK'); }, flowScheduler, dialogCancelScheduler);\n"
405
+ "psychoJS.scheduleCondition(function() { return (psychoJS.gui.dialogComponent.button === 'OK'); },"
406
+ "flowScheduler, dialogCancelScheduler);\n"
405
407
  "\n")
406
408
  script.writeIndentedLines(code)
407
409
 
408
410
  code = ("// flowScheduler gets run if the participants presses OK\n"
409
- "flowScheduler.add(updateInfo); // add timeStamp\n"
410
- "flowScheduler.add(experimentInit);\n")
411
+ "flowScheduler.add(updateInfo); // add timeStamp\n"
412
+ "flowScheduler.add(experimentInit);\n")
411
413
  script.writeIndentedLines(code)
412
414
  loopStack = []
413
415
  for thisEntry in self: