def write(self, 
              text,                     # the text to display
              duration=1.0,             # duration for which the text will be displayed
                                        # if this is a string, the stimulus will be displayed until the corresponding event is generated
                                        # if this is a list of [number,string], the stimulus will at least be displayed for <number> seconds, but needs to confirmed with the respective event
                                        # if this is 0, the write will be non-blocking and you have to .destroy() the return value of this function manually  
              block=True,               # whether to wait for the duration until the function returns
              # optional parameters:
              pos=(0,0),                # x/y position of the text on the screen
              roll=0,                   # roll angle of the text
              scale=0.07,               # size of the text; either a single float (e.g. 0.07) or a 2-tuple of floats for non-uniform scaling
              fg=None,                  # the (r,g,b,a) color of the text; usually each is a floats between 0 and 1
              bg=None,                  # the (r,g,b,a) color of the text background; if a is zero, no background will be created
              shadow=None,              # the (r,g,b,a) color of the text's shadow
              shadowOffset=(0.04,0.04), # offset of the drop shadow from the text
              frame=None,               # the (r,g,b,a) color of the text's frame, drawn around the background (if desired)
              align='center',           # either 'left', 'center', or 'right'
              wordwrap=None,            # optionally the width to wordwrap the text at
              drawOrder=None,           # optional drawing order
              font='arial.ttf',         # optionally the font of the text (see loader.loadFont)
              parent=None,              # parent rendering context or Panda3d NodePath
              sort=0                    # sorting order of the text
              ):
        """Write a piece of text on the screen and keep it there for a particular duration."""
        
        if align == 'left':
            align = self._engine.pandac.TextNode.ALeft
        elif align == 'right':
            align = self._engine.pandac.TextNode.ARight
        else:
            align = self._engine.pandac.TextNode.ACenter
        if duration == 0:
            block = False
        
        if type(font) == str:
            font = self._engine.base.loader.loadFont(font)
        obj = self._engine.direct.gui.OnscreenText.OnscreenText(text=text,pos=(pos[0],pos[1]-scale/4),roll=roll,scale=scale,fg=fg,bg=bg,shadow=shadow,shadowOffset=shadowOffset,frame=frame,align=align,wordwrap=wordwrap,drawOrder=drawOrder,font=font,parent=parent,sort=sort)
        self._to_destroy.append(obj)
        if self.implicit_markers:
            self.marker(254)
        if block:
            if type(duration) == list or type(duration) == tuple:
                self.sleep(duration[0])
                self.waitfor(duration[1])
            elif type(duration) == str:
                self.waitfor(duration)
            else:
                self.sleep(duration)
                
            self._destroy_object(obj,255)
        else:
            if duration > 0:
                self._engine.base.taskMgr.doMethodLater(duration, self._destroy_object, 'ConvenienceFunctions, remove_text',extraArgs=[obj,255])
            return obj
dataset/ETHPy150Open sccn/SNAP/src/framework/basicstimuli.py/BasicStimuli.write/original