Skip to content

Commit 9e02995

Browse files
committed
BF: Add depth parameter to Slider writeInitCode
Add depth parameter to Slider writeInitCode and writeInitCodeJS methods so sliders are rendered in the same order they are displayed in the routine canvas.
1 parent b3b55f3 commit 9e02995

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

psychopy/experiment/components/slider/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,15 @@ def writeInitCode(self, buff):
177177
if inits['units'].val == 'from exp settings':
178178
inits['units'].val = None
179179

180+
inits['depth'] = -self.getPosInRoutine()
181+
180182
# build up an initialization string for Slider():
181183
initStr = ("{name} = visual.Slider(win=win, name='{name}',\n"
182184
" size={size}, pos={pos}, units={units},\n"
183185
" labels={labels}, ticks={ticks},\n"
184186
" granularity={granularity}, style={styles},\n"
185187
" color={color}, font={font},\n"
186-
" flip={flip})\n"
188+
" flip={flip}, depth={depth})\n"
187189
.format(**inits))
188190
buff.writeIndented(initStr)
189191

@@ -222,14 +224,16 @@ def writeInitCodeJS(self, buff):
222224
inits['styles'].val += ','
223225
inits['styles'].val = py2js.expression2js(inits['styles'].val)
224226

227+
inits['depth'] = -self.getPosInRoutine()
228+
225229
# build up an initialization string for Slider():
226230
initStr = ("{name} = new visual.Slider({{\n"
227231
" win: psychoJS.window, name: '{name}',\n"
228232
" size: {size}, pos: {pos}, units: {units},\n"
229233
" labels: {labels}, ticks: {ticks},\n"
230234
" granularity: {granularity}, style: {styles},\n"
231235
" color: new util.Color({color}), \n"
232-
" fontFamily: {font}, bold: true, italic: false, \n"
236+
" fontFamily: {font}, bold: true, italic: false, depth: {depth}, \n"
233237
).format(**inits)
234238
initStr += (" flip: {flip},\n"
235239
"}});\n\n").format(flip=boolConverter[inits['flip'].val])

0 commit comments

Comments
 (0)