MCPcopy Create free account
hub / github.com/brain-workshop/brainworkshop / __init__

Method __init__

brainworkshop.py:2994–3063  ·  view source on GitHub ↗

Generic text label for giving user feedback during N-back sessions. All of the feedback labels should be instances of this class. pos should be which label number this one is displayed as (order: left-to-right). total should be the total number of feedback labels f

(self, modality, pos=0, total=1)

Source from the content-addressed store, hash-verified

2992
2993class FeedbackLabel:
2994 def __init__(self, modality, pos=0, total=1):
2995 """
2996 Generic text label for giving user feedback during N-back sessions. All
2997 of the feedback labels should be instances of this class.
2998
2999 pos should be which label number this one is displayed as (order: left-to-right).
3000 total should be the total number of feedback labels for this mode.
3001 """
3002 self.modality = modality
3003 self.letter = key.symbol_string(cfg['KEY_%s' % modality.upper()])
3004 if self.letter == 'SEMICOLON':
3005 self.letter = ';'
3006 modalityname = modality
3007 if modalityname.endswith('vis'):
3008 modalityname = modalityname[:-3] + ' & n-vis'
3009 elif modalityname.endswith('audio') and not modalityname == 'audio':
3010 modalityname = modalityname[:-5] + ' & n-audio'
3011 if mode.flags[mode.mode]['multi'] == 1 and modalityname == 'position1':
3012 modalityname = 'position'
3013
3014 if total == 2 and not cfg.JAEGGI_MODE and cfg.ENABLE_MOUSE:
3015 if pos == 0:
3016 self.mousetext = "Left-click or"
3017 if pos == 1:
3018 self.mousetext = "Right-click or"
3019 else:
3020 self.mousetext = ""
3021
3022 self.text = "%s %s: %s" % (_(self.mousetext), self.letter, _(modalityname)) # FIXME: will this break pyglettext?
3023
3024 if total < 4:
3025 self.text += _(' match')
3026 font_size=calc_fontsize(16)
3027 elif total < 5: font_size=calc_fontsize(14)
3028 elif total < 6: font_size=calc_fontsize(13)
3029 else: font_size=calc_fontsize(11)
3030
3031 self.label = pyglet.text.Label(
3032 text=self.text,
3033 x=-200, y=from_bottom_edge(30), # we'll fix the x position later, after we see how big the label is
3034 anchor_x='left', anchor_y='center', batch=batch, font_size=font_size)
3035 #w = self.label.width # this doesn't work; how are you supposed to find the width of a label texture?
3036 w = (len(self.text) * font_size*4)/5
3037 dis = (window.width-100) / float(total-.99)
3038 x = 30 + int( pos*dis - w*pos/(total-.5) )
3039
3040 # draw an icon next to the label for multi-stim mode
3041 if mode.flags[mode.mode]['multi'] > 1 and self.modality[-1].isdigit():
3042 self.id = int(modality[-1])
3043 if cfg.MULTI_MODE == 'color':
3044 self.icon = pyglet.sprite.Sprite(visuals[self.id-1].spr_square[cfg.VISUAL_COLORS[self.id-1]-1].image)
3045 self.icon.scale = .125 * visuals[self.id-1].size / visuals[self.id-1].image_set_size
3046 self.icon.y = from_bottom_edge(22)
3047 self.icon.x = x - 15
3048 x += 15
3049
3050 else: # 'image'
3051 self.icon = pyglet.sprite.Sprite(visuals[self.id-1].images[self.id-1].image)

Callers

nothing calls this directly

Calls 4

updateMethod · 0.95
calc_fontsizeFunction · 0.85
from_bottom_edgeFunction · 0.85
get_colorFunction · 0.85

Tested by

no test coverage detected