marisol.py 文件源码

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

项目:Marisol 作者: wikkiewikkie 项目源码 文件源码
def position(self, c):
        """
        Get the appropriate position on the page for the current text given an area.

        Args:
            c (canvas.Canvas): Page to get the positioning for

        Returns:
            tuple: the position
        """
        if self.area in [Area.TOP_LEFT, Area.TOP_RIGHT]:  # top
            from_bottom = c._pagesize[1]-15  # 15 down from height of page
        elif self.area in [Area.BOTTOM_LEFT, Area.BOTTOM_RIGHT]:  # bottom
            from_bottom = 15  # 15 up from bottom of page

        if self.area in [Area.TOP_LEFT, Area.BOTTOM_LEFT]:  # left
            from_left = 15
        elif self.area in [Area.TOP_RIGHT, Area.BOTTOM_RIGHT]:  # right
            offset = 15  # initial offset
            offset += c.stringWidth(self.text)  # offset for text length
            from_left = c._pagesize[0]-offset

        return from_left, from_bottom
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号