示例#1
0
    def draw(self, basis):
        text = self.platform.track
        fontwh = basis.textsize(self.text, self.font)
        if text != self.rawtext:
            self.rawtext = text

            self.font, self.fontwh = scalefont(self.display, self.wh, text,
                                               "arial.ttf")
            # print("TrackFrame.draw> Scale Down w,h %s, text len  <%d>, fontwh %s" % ( self.wh,len(text), self.fontwh) )

            if self.fontwh[1] < (self.h / 2) - 1:
                self.font = make_font("arial.ttf", (self.h / 2) - 1)
                onecharwh = basis.textsize('2', self.font)
                self.charw = int(
                    self.w / onecharwh[0])  #how many characters wide will fit?
                textlines = wrap(text, width=self.charw)
                print(textlines)
                if len(textlines) > 0:
                    text = textlines[0].center(
                        self.charw) + '\n' + textlines[1].center(self.charw)
                # print("TrackFrame.draw> Wrap w,h %s, charw %d, len  <%d>" % ( self.wh, self.charw,len(self.text)) )

            # print("TrackFrame.draw> w,h : text size for:", self.w, self.h, basis.textsize(text, self.font), text)
            self.text = text
            self.display.drawFrameCentredText(basis, self, self.text,
                                              self.font)
        else:
            self.display.drawFrameCentredText(basis, self, self.text,
                                              self.font)
示例#2
0
    def __init__(self,
                 bounds,
                 platform,
                 display,
                 V,
                 Y,
                 text='',
                 X=1.0,
                 H='centre'):
        Frame.__init__(self,
                       bounds=bounds,
                       platform=platform,
                       display=display,
                       scalers=(X, Y),
                       Valign=V,
                       Halign=H)
        # scale the font so the widest fits
        self.text = text
        self.rawtext = text

        if text != '':
            self.font, self.fontwh = scalefont(display, self.wh, text,
                                               "arial.ttf")
            self.charw = int(
                self.w / (self.fontwh[0] / len(text))
            ) - 1  #  be safe as rounds down how many characters wide will fit?
        else:
            self.font = make_font("arial.ttf", self.h / 2)
            self.fontwh = display.textsize('2', self.font)
            self.charw = int(
                self.w / self.fontwh[0]
            ) - 1  # be safe as rounds down how many characters wide will fit?
示例#3
0
    def __init__(self, bounds, platform, display,
                 channel):  # size is a horizontal scaling factor
        self.channel = channel

        Frame.__init__(self,
                       platform=platform,
                       bounds=bounds,
                       display=display,
                       scalers=(1.0, 1.0),
                       Valign='top',
                       Halign=channel)
        self.font = make_font("arial.ttf", self.h * VUMeterBackground.FONTH)
示例#4
0
    def __init__(self, bounds, platform, display, channel, limits):  # size is a scaling factor
        self.limits  = limits
        self.channel = channel
        if channel == 'left':
            self.ch_text = 'L'
            V    = 'top'
        elif channel == 'right':
            self.ch_text = 'R'
            V    = 'bottom'
        else:
            raise ValueError('VUFrame.__init__> unknown channel', channel)

        Frame.__init__(self, platform=platform, bounds=bounds, display=display, scalers=(0.5, 0.5), Valign=V, Halign='left')
        self.font   = make_font("arial.ttf", self.h*VUFrame.BARHEIGHT)
示例#5
0
 def __init__(self, bounds, platform, display):
     Frame.__init__(self, platform=platform, bounds=bounds, display=display, scalers=(1.0,0.4), Valign='top', Halign='centre')
     self.font   = make_font("arial.ttf", self.h)
示例#6
0
 def __init__(self, bounds, platform, display, text=''):
     Frame.__init__(self, platform=platform, bounds=bounds, display=display, scalers=(0.4,0.4), Valign='middle', Halign='right')
     self.text   = text
     self.font   = make_font("arial.ttf", self.h)
示例#7
0
 def __init__(self, bounds, platform, display):
     Frame.__init__(self, platform=platform, bounds=bounds, display=display, scalers=(0.5,1.0), Valign='bottom', Halign='right')
     self.font = make_font("arial.ttf", 24)