live_scoreboard.py 文件源码

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

项目:live_scoreboard 作者: ClysmiC 项目源码 文件源码
def __init__(self, x, y, panelWidth, panelHeight):
        self.width = panelWidth
        self.height = panelHeight
        self.x = x
        self.y = y

        self.canvas = tk.Canvas(root, width=self.width, height=self.height, background=panelBackground, highlightthickness=0)
        self.canvas.place(x=self.x, y=self.y)

        self.topHeightPercent = 0.85 # main box score
        self.botHeightPercent = 1 - self.topHeightPercent # win/loss/save pitcher info, post game

        #                         1  2  3  4  5  6  7  8  9   R  H  E
        exampleString = "*  STL  10 10 10 10 10 10 10 10 10  10 10 10"

        topNumLines = 3
        lineHeightMultiplier = 1.2

        self.topFont, self.topFontHeight = fontFit(fontName, exampleString, (self.width * .9, self.height * self.topHeightPercent // topNumLines // lineHeightMultiplier))
        self.topLineHeight = self.topFontHeight * lineHeightMultiplier
        self.topUnderlinedFont = tkFont.Font(family=fontName, size=-self.topFontHeight, underline=1)

        self.topStartLineY = (self.height * self.topHeightPercent - self.topLineHeight * topNumLines) // 2
        self.topStartX = (self.width - self.topFont.measure(exampleString)) // 2
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号