def resize(self, screen): Background.resize(self, screen) if self._need_update: size = (self._rect.width * 0.6, self._rect.height * 0.6) self.layout0 = pictures.get_pygame_layout_image( self._text_color, self._background_color, self.choices[0], size) self.layout1 = pictures.get_pygame_layout_image( self._text_color, self._background_color, self.choices[1], size) inter = (self._rect.width - 2 * self.layout0.get_rect().width) // 3 x0 = int(self._rect.left + inter) x1 = int(self._rect.left + 2 * inter + self.layout0.get_rect().width) y = int(self._rect.top + self._rect.height * 0.3) self.layout0_pos = (x0, y) self.layout1_pos = (x1, y) if self.arrow_location != ARROW_HIDDEN: if self.arrow_location == ARROW_TOP: y = 5 x_offset = 30 size = (self._rect.width * 0.1, self._rect.top + y + 30) else: x_offset = 0 y = self.layout0_pos[1] + self.layout0.get_rect( ).height + 5 size = (self._rect.width * 0.1, self._rect.bottom - y - 5) vflip = True if self.arrow_location == ARROW_TOP else False self.left_arrow = pictures.get_pygame_image( "arrow.png", size, vflip=vflip, color=self._text_color) self.right_arrow = pictures.get_pygame_image( "arrow.png", size, hflip=True, vflip=vflip, color=self._text_color) inter = (self._rect.width - 2 * self.left_arrow.get_rect().width) // 4 x0 = int(self._rect.left + inter) - x_offset x1 = int(self._rect.left + 3 * inter + self.left_arrow.get_rect().width) + x_offset self.left_arrow_pos = (x0 - self.arrow_offset, y) self.right_arrow_pos = (x1 + self.arrow_offset, y)
def resize(self, screen): Background.resize(self, screen) if self._need_update: size = (self._rect.width * 0.6, self._rect.height * 0.6) self.layout = pictures.get_pygame_layout_image( self._text_color, self._background_color, self.selected, size) x = self.layout.get_rect(center=self._rect.center).left y = int(self._rect.top + self._rect.height * 0.3) self.layout_pos = (x, y)