MSBrowser.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:PiStorms 作者: mindsensors 项目源码 文件源码
def drawHostnameTitle():
    size = 30
    maxWidth = 320-50-50-5-5 # screen width is 320, each arrow is 50px wide, 5px margin
    if newMessageExists() or updateNeeded():
        maxWidth -= 44
    getTextSize = ImageDraw.Draw(scrn.disp.buffer).textsize
    font = ImageFont.truetype("/usr/share/fonts/truetype/freefont/FreeSans.ttf", size)
    width, height = getTextSize(deviceName, font=font)
    while (width > maxWidth):
        size -= 1
        font = ImageFont.truetype("/usr/share/fonts/truetype/freefont/FreeSans.ttf", size)
        width, height = getTextSize(deviceName, font=font)
    scrn.fillRect(55, 0, maxWidth, 50, fill=(0,0,0), display=False)
    if (newMessageExists() or updateNeeded()) and width > 135:
        scrn.drawAutoText(deviceName, 60, (50-height)/2-5, fill=(0,255,255), size=size, display=False)
    else:
        scrn.drawAutoText(deviceName, 0, (50-height)/2-5, fill=(0,255,255), size=size, display=False, align="center")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号