更新 'button.py'

This commit is contained in:
206530212 2021-06-23 19:15:14 +08:00
parent dc9cf3b546
commit 7341a596e8
1 changed files with 7 additions and 0 deletions

View File

@ -20,3 +20,10 @@ class Button():
# 按钮的标签只需创建一次
self.prep_msg(msg)
def prep_msg(self, msg):
"""将msg渲染为图像并使其在按钮上居中"""
self.msg_image = self.font.render(msg, True, self.text_color,
self.button_color)
self.msg_image_rect = self.msg_image.get_rect()
self.msg_image_rect.center = self.rect.center