How to use the pibooth.view.background.Background function in pibooth

To help you get started, we’ve selected a few pibooth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github werdeil / pibooth / pibooth / view / background.py View on Github external
self._rect.width // 5 - 2 * self._text_border,
                                   self._rect.height * 0.3 - 2 * self._text_border)
            else:
                rect = pygame.Rect(self._rect.width // 2 + self._text_border, self._text_border,
                                   self._rect.width // 5 - 2 * self._text_border,
                                   self._rect.height * 0.3 - 2 * self._text_border)
            self._write_text(text, rect)

    def paint(self, screen):
        Background.paint(self, screen)
        if self.arrow_location != ARROW_HIDDEN:
            screen.blit(self.right_arrow, self.right_arrow_pos)
            screen.blit(self.left_arrow, self.left_arrow_pos)


class FinishedBackground(Background):

    def __init__(self):
        Background.__init__(self, "finished")

    def resize_texts(self):
        """Update text surfaces.
        """
        rect = pygame.Rect(self._rect.width * 0.3, self._rect.height * 0.6 - self._text_border,
                           self._rect.width * 0.4, self._rect.height * 0.4)
        Background.resize_texts(self, rect)


class OopsBackground(Background):

    def __init__(self):
        Background.__init__(self, "oops")
github werdeil / pibooth / pibooth / view / background.py View on Github external
if self.arrow_location == ARROW_HIDDEN:
            rect = pygame.Rect(self._rect.width / 2 + self._text_border, self._text_border,
                               self._rect.width / 2 - 2 * self._text_border,
                               self._rect.height - 2 * self._text_border)
            align = 'center'
        elif self.arrow_location == ARROW_BOTTOM:
            rect = pygame.Rect(self._rect.width / 2 + self._text_border, self._text_border,
                               self._rect.width / 2 - 2 * self._text_border,
                               self._rect.height * 0.6 - self._text_border)
            align = 'bottom-center'
        else:
            rect = pygame.Rect(self._rect.width / 2 + self._text_border, self._rect.height * 0.4,
                               self._rect.width / 2 - 2 * self._text_border,
                               self._rect.height * 0.6 - self._text_border)
            align = 'top-center'
        Background.resize_texts(self, rect, align)

        text = get_translated_text("print_forget")
        if text:
            if self.arrow_location == ARROW_HIDDEN or self.arrow_location == ARROW_BOTTOM:
                rect = pygame.Rect(self._rect.width // 2 + self._text_border, self._rect.height * 0.7,
                                   self._rect.width // 5 - 2 * self._text_border,
                                   self._rect.height * 0.3 - 2 * self._text_border)
            else:
                rect = pygame.Rect(self._rect.width // 2 + self._text_border, self._text_border,
                                   self._rect.width // 5 - 2 * self._text_border,
                                   self._rect.height * 0.3 - 2 * self._text_border)
            self._write_text(text, rect)
github werdeil / pibooth / pibooth / view / background.py View on Github external
rect = pygame.Rect(self._rect.width * 0.30 + self._text_border, self._rect.height * 0.7,
                                   self._rect.width * 0.20 - 2 * self._text_border,
                                   self._rect.height * 0.3 - 2 * self._text_border)
            else:
                rect = pygame.Rect(self._rect.width * 0.30 + self._text_border, self._text_border,
                                   self._rect.width * 0.20 - 2 * self._text_border,
                                   self._rect.height * 0.3 - 2 * self._text_border)
            self._write_text(text, rect)

    def paint(self, screen):
        IntroBackground.paint(self, screen)
        if self.arrow_location != ARROW_HIDDEN:
            screen.blit(self.right_arrow, self.right_arrow_pos)


class ChooseBackground(Background):

    def __init__(self, choices, arrow_location=ARROW_BOTTOM, arrow_offset=0):
        Background.__init__(self, "choose")
        self.arrow_location = arrow_location
        self.arrow_offset = arrow_offset
        self.choices = choices
        self.layout0 = None
        self.layout0_pos = None
        self.layout1 = None
        self.layout1_pos = None
        self.left_arrow = None
        self.left_arrow_pos = None
        self.right_arrow = None
        self.right_arrow_pos = None

    def resize(self, screen):
github werdeil / pibooth / pibooth / view / background.py View on Github external
"""Update text surfaces.
        """
        rect = pygame.Rect(self._text_border, self._text_border,
                           self._rect.width - 2 * self._text_border, self._rect.height * 0.2)
        Background.resize_texts(self, rect)

    def paint(self, screen):
        Background.paint(self, screen)
        screen.blit(self.layout0, self.layout0_pos)
        screen.blit(self.layout1, self.layout1_pos)
        if self.arrow_location != ARROW_HIDDEN:
            screen.blit(self.left_arrow, self.left_arrow_pos)
            screen.blit(self.right_arrow, self.right_arrow_pos)


class ChosenBackground(Background):

    def __init__(self, choices, selected):
        Background.__init__(self, "chosen")
        self.choices = choices
        self.selected = selected
        self.layout = None
        self.layout_pos = None

    def __str__(self):
        """Return background final name.
        It is used in the main window to distinguish background in the cache.
        """
        return "{}({}{})".format(self.__class__.__name__, self._name, self.selected)

    def resize(self, screen):
        Background.resize(self, screen)
github werdeil / pibooth / pibooth / view / background.py View on Github external
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 paint(self, screen):
        Background.paint(self, screen)
        screen.blit(self.left_people, self.left_people_pos)
        screen.blit(self.right_people, self.right_people_pos)


class ProcessingBackground(Background):

    def __init__(self):
        Background.__init__(self, "processing")

    def resize_texts(self):
        """Update text surfaces.
        """
        rect = pygame.Rect(self._text_border, self._rect.height * 0.8 - self._text_border,
                           self._rect.width - 2 * self._text_border, self._rect.height * 0.2)
        Background.resize_texts(self, rect)


class PrintBackground(Background):

    def __init__(self, arrow_location=ARROW_BOTTOM, arrow_offset=0):
        Background.__init__(self, "print")
github werdeil / pibooth / pibooth / view / background.py View on Github external
def paint(self, screen):
        Background.paint(self, screen)
        screen.blit(self.left_people, self.left_people_pos)
        screen.blit(self.right_people, self.right_people_pos)
github werdeil / pibooth / pibooth / view / background.py View on Github external
def paint(self, screen):
        """Paint and animate the surfaces on the screen.
        """
        if self._background:
            screen.blit(self._background, (0, 0))
        else:
            screen.fill(self._background_color)
        if self._overlay:
            screen.blit(self._overlay, self._overlay.get_rect(center=self._rect.center))
        for text_surface, pos in self._texts:
            screen.blit(text_surface, pos)
        self._need_update = False


class IntroBackground(Background):

    def __init__(self, arrow_location=ARROW_BOTTOM, arrow_offset=0):
        Background.__init__(self, "intro")
        self.arrow_location = arrow_location
        self.arrow_offset = arrow_offset
        self.left_arrow = None
        self.left_arrow_pos = None

    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)
github werdeil / pibooth / pibooth / view / background.py View on Github external
self.layout_pos = (x, y)

    def resize_texts(self):
        """Update text surfaces.
        """
        rect = pygame.Rect(self._text_border, self._text_border,
                           self._rect.width - 2 * self._text_border, self._rect.height * 0.2)
        Background.resize_texts(self, rect)

    def paint(self, screen):
        Background.paint(self, screen)
        screen.blit(self.layout, self.layout_pos)


class CaptureBackground(Background):

    def __init__(self):
        Background.__init__(self, "capture")
        self.left_people = None
        self.left_people_pos = None
        self.right_people = None
        self.right_people_pos = None

    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)
github werdeil / pibooth / pibooth / view / background.py View on Github external
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)
github werdeil / pibooth / pibooth / view / background.py View on Github external
class ProcessingBackground(Background):

    def __init__(self):
        Background.__init__(self, "processing")

    def resize_texts(self):
        """Update text surfaces.
        """
        rect = pygame.Rect(self._text_border, self._rect.height * 0.8 - self._text_border,
                           self._rect.width - 2 * self._text_border, self._rect.height * 0.2)
        Background.resize_texts(self, rect)


class PrintBackground(Background):

    def __init__(self, arrow_location=ARROW_BOTTOM, arrow_offset=0):
        Background.__init__(self, "print")
        self.arrow_location = arrow_location
        self.arrow_offset = arrow_offset
        self.right_arrow = None
        self.right_arrow_pos = None
        self.left_arrow = None
        self.left_arrow_pos = None

    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