From 5f335fa9b556ae74c99c93de608489e30557d1be Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sun, 20 Aug 2023 01:52:22 +0800 Subject: [PATCH] button gogogo --- .../gui/{widgets.py => widget/button.py} | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) rename Difficult_Rocket/gui/{widgets.py => widget/button.py} (63%) diff --git a/Difficult_Rocket/gui/widgets.py b/Difficult_Rocket/gui/widget/button.py similarity index 63% rename from Difficult_Rocket/gui/widgets.py rename to Difficult_Rocket/gui/widget/button.py index 000877d..6f67d86 100644 --- a/Difficult_Rocket/gui/widgets.py +++ b/Difficult_Rocket/gui/widget/button.py @@ -41,10 +41,26 @@ class TextButton(widgets.WidgetBase): width: int, height: int, text: str, - font: str = Fonts.鸿蒙简体, font_size: int = 13): + font: str = Fonts.鸿蒙简体, + font_size: int = 13, + batch: Optional[Batch] = None, + group: Optional[Group] = None, + ): super().__init__(x, y, width, height) + self.back_ground_batch = Batch() + self.front_batch = batch or Batch() + if group: + self.front_group = Group(order=5, parent=group) + self.back_ground_group = Group(order=10, parent=group) + else: + self.front_group = Group(order=5) + self.back_ground_group = Group(order=10) + self.text = text - self.text_label = Label(font_name=font, font_size=font_size) + self.text_label = Label(font_name=font, font_size=font_size, + batch=self.front_batch, group=self.front_group) + self.back_rec = Rectangle(x=self._x, y=self._y, width=self._width, height=self._height, + batch=self.back_ground_batch, group=self.back_ground_group) @property def value(self):