Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def resize(self, screen):
Background.resize(self, screen)
if self._need_update and self.arrow_location != ARROW_HIDDEN:
size = (self._rect.width * 0.3, self._rect.height * 0.3)
vflip = True if self.arrow_location == ARROW_TOP else False
# Right arrow
self.right_arrow = pictures.get_pygame_image(
"arrow.png", size, hflip=True, vflip=vflip, color=self._text_color)
x = int(self._rect.left + self._rect.width * 0.75
- self.right_arrow.get_rect().width // 2)
if self.arrow_location == ARROW_TOP:
y = self._rect.top + 10
else:
y = int(self._rect.top + 2 * self._rect.height // 3)
self.right_arrow_pos = (x + self.arrow_offset, y)
# Left arrow
size = (self._rect.width * 0.1, self._rect.height * 0.1)
angle = 70 if self.arrow_location == ARROW_TOP else -70
self.left_arrow = pictures.get_pygame_image(
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 and self.arrow_location != ARROW_HIDDEN:
size = (self._rect.width * 0.3, self._rect.height * 0.3)
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)
x = int(self._rect.left + self._rect.width // 4
- self.left_arrow.get_rect().width // 2)
if self.arrow_location == ARROW_TOP:
y = self._rect.top + 10
else:
y = int(self._rect.top + 2 * self._rect.height // 3)
self.left_arrow_pos = (x - self.arrow_offset, y)
def _update_print_number(self):
"""Update the number of files in the printer queue.
"""
if not self._print_number and not self._print_failure:
return # Dont show counter: no file in queue, no failure
smaller = self.surface.get_size()[1] if self.surface.get_size(
)[1] < self.surface.get_size()[0] else self.surface.get_size()[0]
side = int(smaller * 0.05) # 5% of the window
if side > 0:
if self._print_failure:
image = pictures.get_pygame_image('printer_failure.png', (side, side), color=self.text_color)
else:
image = pictures.get_pygame_image('printer.png', (side, side), color=self.text_color)
y = self.surface.get_rect().height - image.get_rect().height - 10
self.surface.blit(image, (10, y))
font = pygame.font.Font(fonts.CURRENT, side)
label = font.render(str(self._print_number), True, self.text_color)
self.surface.blit(label, (side + 20, y))
def _update_print_number(self):
"""Update the number of files in the printer queue.
"""
if not self._print_number and not self._print_failure:
return # Dont show counter: no file in queue, no failure
smaller = self.surface.get_size()[1] if self.surface.get_size(
)[1] < self.surface.get_size()[0] else self.surface.get_size()[0]
side = int(smaller * 0.05) # 5% of the window
if side > 0:
if self._print_failure:
image = pictures.get_pygame_image('printer_failure.png', (side, side), color=self.text_color)
else:
image = pictures.get_pygame_image('printer.png', (side, side), color=self.text_color)
y = self.surface.get_rect().height - image.get_rect().height - 10
self.surface.blit(image, (10, y))
font = pygame.font.Font(fonts.CURRENT, side)
label = font.render(str(self._print_number), True, self.text_color)
self.surface.blit(label, (side + 20, y))
def resize(self, screen):
Background.resize(self, screen)
if self._need_update:
images_height = self._rect.height / 4
size = (3 * images_height, images_height)
self.left_people = pictures.get_pygame_image("capture_left_image.png", size=size,
color=self._text_color)
self.right_people = pictures.get_pygame_image("capture_right_image.png", size=size,
color=self._text_color)
x = int(self._rect.right - 2 * self.right_people.get_rect().width)
y = int(self._rect.bottom - images_height)
self.left_people_pos = (0, y)
self.right_people_pos = (x, y)
def resize(self, screen):
"""Resize objects to fit to the screen.
"""
if self._rect != screen.get_rect():
self._rect = screen.get_rect()
if self._background_image:
self._background = pictures.get_pygame_image(
self._background_image, (self._rect.width, self._rect.height), crop=True, color=None)
self._background_color = pictures.get_pygame_main_color(self._background)
overlay_name = "{}.png".format(self._name)
if osp.isfile(pictures.get_filename(overlay_name)):
self._overlay = pictures.get_pygame_image(
pictures.get_filename(overlay_name), (self._rect.width, self._rect.height), color=self._text_color, bg_color=self._background_color)
self.resize_texts()
self._need_update = True
def resize(self, screen):
"""Resize objects to fit to the screen.
"""
if self._rect != screen.get_rect():
self._rect = screen.get_rect()
if self._background_image:
self._background = pictures.get_pygame_image(
self._background_image, (self._rect.width, self._rect.height), crop=True, color=None)
self._background_color = pictures.get_pygame_main_color(self._background)
overlay_name = "{}.png".format(self._name)
if osp.isfile(pictures.get_filename(overlay_name)):
self._overlay = pictures.get_pygame_image(
pictures.get_filename(overlay_name), (self._rect.width, self._rect.height), color=self._text_color, bg_color=self._background_color)
self.resize_texts()
self._need_update = True