trayicon.py 文件源码

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

项目:bittray 作者: nkuttler 项目源码 文件源码
def get_icon(self, text):
        """
        Return a wx icon from a file like object containing the image
        with text.

        TODO: transparency support
        """
        background = self.conf.get_color('Look', 'background')
        foreground = self.conf.get_color('Look', 'color')
        font = ImageFont.truetype(
            self.conf.get_font_path(),
            self.conf.get_int('Look', 'size'),
        )
        if font is None:
            logger.critical("Font could not be looked up. Try setting "
                            "font_path in the configuration file to the full "
                            "path to a truetype font.")
        mask = Image.new('RGB', (WIDTH, HEIGHT), background)
        draw = ImageDraw.Draw(mask)
        draw.text(
            background,
            text,
            font=font,
            fill=foreground,
        )
        mask = self.trim(mask)
        buf = io.StringIO()
        mask.save(buf, 'png')
        buf.seek(0)
        icon = wx.IconFromBitmap(
            wx.BitmapFromImage(
                wx.ImageFromStream(
                    buf,
                    wx.BITMAP_TYPE_PNG
                )
            )
        )
        return icon
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号