Skip to content

Commit

Permalink
BF: Add depth parameter to Slider writeInitCode
Browse files Browse the repository at this point in the history
Add depth parameter to Slider writeInitCode and writeInitCodeJS
methods so sliders are rendered in the same order they are displayed
in the routine canvas.
  • Loading branch information
pn2200 committed Sep 22, 2020
1 parent b3b55f3 commit 9e02995
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions psychopy/experiment/components/slider/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,15 @@ def writeInitCode(self, buff):
if inits['units'].val == 'from exp settings':
inits['units'].val = None

inits['depth'] = -self.getPosInRoutine()

# build up an initialization string for Slider():
initStr = ("{name} = visual.Slider(win=win, name='{name}',\n"
" size={size}, pos={pos}, units={units},\n"
" labels={labels}, ticks={ticks},\n"
" granularity={granularity}, style={styles},\n"
" color={color}, font={font},\n"
" flip={flip})\n"
" flip={flip}, depth={depth})\n"
.format(**inits))
buff.writeIndented(initStr)

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

inits['depth'] = -self.getPosInRoutine()

# build up an initialization string for Slider():
initStr = ("{name} = new visual.Slider({{\n"
" win: psychoJS.window, name: '{name}',\n"
" size: {size}, pos: {pos}, units: {units},\n"
" labels: {labels}, ticks: {ticks},\n"
" granularity: {granularity}, style: {styles},\n"
" color: new util.Color({color}), \n"
" fontFamily: {font}, bold: true, italic: false, \n"
" fontFamily: {font}, bold: true, italic: false, depth: {depth}, \n"
).format(**inits)
initStr += (" flip: {flip},\n"
"}});\n\n").format(flip=boolConverter[inits['flip'].val])
Expand Down

0 comments on commit 9e02995

Please sign in to comment.