Beispiel #1
0
 def __init__(self):
     import infosys
     self.infosys = infosys.get_infosys()
     self.set_margins((0, 160, 1, 25))
     weather = self.infosys.registry.Weather
     ff = figlet.FigletFormatter("fraktur")
     ff = figlet.FigletFormatter()
     temp = ff.format(weather.current_temperature)
     sp = vt220.Sprite()
     sp.set_buffer(temp)
     super(Temperature, self).__init__(sp)
     self.count = random.randint(100, 200)
Beispiel #2
0
 def layout(self, text, page=None):
     if page == None:
         page = Page()
     ff = figlet.FigletFormatter(self.current_font)
     self.home_cursor()
     self.get_font_height(text)
     words = text.split(' ')
     lw = 0
     rw = len(words)
     spc = ' '
     while True:
         if lw == rw:
             break
         if (self.y + self.font_height) > self.height:
             break
         nrw = self.boundtext(words[lw:rw]) + lw
         sp = Sprite()
         msg = spc.join(words[lw:nrw])
         # justification
         xoff = 0
         sp.set_buffer(ff.format(msg))
         if self.justification == self.CENTER:
             if not self.clip_right_screen(self.x):
                 xoff = ((self.midline - self.left_margin) - sp.width) / 2
             else:
                 xoff = ((self.right_margin - self.midline) - sp.width) / 2
         if self.justification == self.RIGHT:
             if not self.clip_right_screen(self.x):
                 xoff = ((self.midline - self.left_margin) - sp.width)
             else:
                 xoff = ((self.right_margin - self.midline) - sp.width)
         sp.set_position(self.x + xoff, self.y)
         sp.draw(page)
         lw = nrw
         if self.textflow == TypeSetter.ACROSS:
             if not self.clip_right_screen(self.x) and \
                 self.clip_right_screen(self.right_margin):
                 # screen hop
                 self.x = self.midline + 1
             else:
                 # move down one line
                 self.x = self.left_margin
                 self.y += self.font_height
         elif self.textflow == TypeSetter.DOWN:
             if ((self.y + self.font_height*2) > self.height) and \
                 not self.clip_right_screen(self.x) and \
                 self.clip_right_screen(self.right_margin):
                 # screen hop
                 self.x = self.midline + 1
                 self.y = self.top_margin
             else:
                 # move down one line
                 if self.clip_right_screen(self.x):
                     self.x = self.midline + 1
                 else:
                     self.x = self.left_margin
                 self.y += self.font_height
     return str.join(" ", words[lw:rw])
Beispiel #3
0
 def boundtext(self, words):
     rw = len(words)
     ff = figlet.FigletFormatter(self.current_font)
     spc = ' '
     rw = len(words)
     lw = 0
     if not self.clip_right_screen(self.x) and \
         self.clip_right_screen(self.right_margin):
         width = self.midline - self.x
     else:
         width = self.right_margin - self.x
     while lw != rw:
         msg = spc.join(words[0:lw + 1])
         msg = ff.format(msg)
         maxline = self.max_line(msg)
         if maxline > width:
             return lw
         else:
             lw += 1
     return lw
Beispiel #4
0
 def get_font_height(self, text=None):
     if text == 'None':
         text = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
     ff = figlet.FigletFormatter(self.current_font)
     tst = ff.format(text)
     self.font_height = len(tst)
Beispiel #5
0
 def initialize_misc(self):
     ff = figlet.FigletFormatter()
     self.registry.Fonts = ff.get_fonts()