Skip to content

Commit a686dbf

Browse files
dvbridgespeircej
authored andcommitted
BF: Replace 'use prefs' default with 'height' for JS window units
'use preferences' for window units breaks JS code. This fix sets the default window units as 'height'. Fixes new issue in #2227.
1 parent aa14f1b commit a686dbf

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

psychopy/experiment/components/settings/__init__.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -723,17 +723,25 @@ def writeWindowCode(self, buff):
723723
buff.writeIndentedLines(code)
724724

725725
def writeWindowCodeJS(self, buff):
726+
"""Setup the JS window code.
727+
"""
728+
# Replace instances of 'use prefs'
729+
units = self.params['Units'].val
730+
if units == 'use prefs':
731+
units = 'height'
732+
726733
code = ("// init psychoJS:\n"
727-
"var psychoJS = new PsychoJS({{\n"
728-
" debug: true\n"
729-
"}});\n\n"
730-
"// open window:\n"
731-
"psychoJS.openWindow({{\n"
732-
" fullscr: {fullScr},\n"
733-
" color: new util.Color({params[color]}),\n"
734-
" units: {params[Units]}\n"
735-
"}});\n").format(fullScr=str(self.params['Full-screen window']).lower(),
736-
params=self.params)
734+
"var psychoJS = new PsychoJS({{\n"
735+
" debug: true\n"
736+
"}});\n\n"
737+
"// open window:\n"
738+
"psychoJS.openWindow({{\n"
739+
" fullscr: {fullScr},\n"
740+
" color: new util.Color({params[color]}),\n"
741+
" units: '{units}'\n"
742+
"}});\n").format(fullScr=str(self.params['Full-screen window']).lower(),
743+
params=self.params,
744+
units=units)
737745
buff.writeIndentedLines(code)
738746

739747
def writeEndCode(self, buff):

0 commit comments

Comments
 (0)