def __init__(self, text, location, dots_per_second=20):
     self.scroll = typefaces.prepare_passage(text, location.width)
     self.location = location
     self.dots_per_second = dots_per_second
     self.end_position = location.height
     self.end_position = self.scroll.get_height() - location.height
     self.position = -location.height
     self.rate = 1
 def push_messages(self, *messages):
     for m in messages:
         if len(self.message_stack) >= 4:
             self.message_stack.pop(-1)
         self.message_stack.insert(0,m)
     self.messages = typefaces.prepare_passage(
         "\n".join(self.message_stack),400,
         colour=(240,240,240), size="small")
def make_titledbox(position,title,text,width,titlesize="subtitle",
                   textsize="normal",gap=12,indent=20,colour=(0,0,0)):
    titlewidget = SurfWidget(
        typefaces.prepare(title,size=titlesize,colour=colour))
    textwidget = SurfWidget(
        typefaces.prepare_passage(text,width-indent*2,size=textsize,colour=colour))
    return TextFrame(position,
                     [titlewidget,
                      SpaceWidget(gap),
                      textwidget],width)
def make_textbox(position,text,width,size="normal",colour=(0,0,0)):
    widget = SurfWidget(
        typefaces.prepare_passage(text,width,size=size,colour=colour))
    return TextFrame(position,[widget],width)