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
评论列表
文章目录