python - psychopy ratingScale with numeric keypad -


in task, i've been allowing responses using numeric keypad (e.g 'num_1') regular numbers @ top of keyboard (e.g. '1'). when later ask ratings using ratingscale, i'd both options available well, don't know how achieve this.

as is, ratingscale not accept responses numeric keypad. can change respkeys, have provide "a list of keys use selecting choices, in desired order". means can't allow both '1' , 'num_1' select first rating (e.g. respkeys = ['1','num_1, '2', 'num_2', ...] '1' select first rating, 'num_1' second, etc.).

am stuck either respkeys = ['1','2','3','4','5'] or respkeys = ['num_1','num_2','num_3','num_4','num_5']?

thanks help!

i don't think there's built-in ways visual.ratingscale take multiple keyboard keys same scale location.

if you're using coder, hack use event.getkeys() , visual.ratingscale.setmarkerpos(). simple case rating scale 3 positions:

# initiate psychopy stuff psychopy import visual, event win = visual.window() scale = visual.ratingscale(win, low=1, high=3)  # list of lists, each sublist being keys represents location keyslocation = [['1', 'num_1'], ['2', 'num_2'], ['3', 'num_3']] respkeys = [key keysloc in keyslocation key in keysloc]  # looks complicated flattens list non-nested      # present ratingscale , wait response     currentpos = 1     while scale.noresponse:         response = event.getkeys(keylist=respkeys)  # accept respkeys         if response , response[0] in respkeys:             # loop through sublists , update currentpos match             i, loc in enumerate(keyslocation):                 if response[0] in loc:                     currentpos =          # set marker position , draw         scale.setmarkerpos(currentpos)         scale.draw()         win.flip() 

my solution looks complicated of handling keyslocationlist , searching matches. sorry bad/ambiguous variable names couldn't come better right now.

this solution work in builder. remove "initiate psychopy" stuff, change scale name of ratingscale, , paste code code component above ratingscale.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -