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)
# Extra space before name for logo
self.logoString = " "
exampleString = "1 " + self.logoString + " STL 100 62 -10.0"
numLines = 9 # 1 for division name, 5 for teams, 2 for padding
lineHeightMultiplier = 1.2 # Multiply font height by this to get line height
self.font, self.fontHeight = fontFit(fontName, exampleString, (self.width * 0.9, self.height // (numLines * lineHeightMultiplier)))
self.underlinedFont = tkFont.Font(family=fontName, size=-self.fontHeight, underline=1)
self.lineHeight = self.fontHeight * lineHeightMultiplier
# Center horizontally
self.startX = (self.width - self.font.measure(exampleString)) // 2
logoRegionWidth = self.font.measure(self.logoString)
logoRegionHeight = self.fontHeight
self.scaledLogos = {}
# Initialize list of MLB team logos
for key, logo in mlbLogos.items():
logoHeight = logo.size[1]
logoWidth = logo.size[0]
scale = min(logoRegionHeight / float(logoHeight),
logoRegionWidth / float(logoWidth))
self.scaledLogos[key] = ImageTk.PhotoImage(logo.resize((int(scale * logoWidth), int(scale * logoHeight))))
self.displayingWildcard = False
self.initiallySet = False
评论列表
文章目录