Exemplo n.º 1
0
    def __init__(self):
        Scene.__init__(self)
        self.callback = self._default_cb

        self.wait_img = Screen.get_instance().create_image(self.get_name() +
                                                           "_wait")
        if not self.wait_img.is_cached():
            img = Screen.create_button(ResourceManager.get("empty.png"),
                                       Strings.get("Please wait..."),
                                       Config.get("text_color"),
                                       ResourceManager.get(Config.get("font")),
                                       100)
            self.wait_img.load_surface(img)
            self.wait_img.save()

        self.nb_imgs = len(Config.get("photomaton")["placeholders"])
        self.one_more_imgs = []
        for i in xrange(self.nb_imgs):
            self.one_more_imgs.append(
                Screen.get_instance().create_image(self.get_name() +
                                                   "_one_more%d" % i))
            if not self.one_more_imgs[i].is_cached():
                img = Screen.create_button(
                    ResourceManager.get("empty.png"),
                    Strings.get(
                        "Encore une... (%d / %d)" % (i + 1, self.nb_imgs)),
                    Config.get("text_color"),
                    ResourceManager.get(Config.get("font")), 100)
                self.one_more_imgs[i].load_surface(img)
                self.one_more_imgs[i].save()
Exemplo n.º 2
0
    def __init__(self, arduino, camera):
        Scene.__init__(self)
        self.arduino = arduino
        self.camera = camera
        self.timer = None
        self.current_step = 0
        self.callback = self._default_cb

        self.cheese_img = Screen.get_instance().create_image(self.get_name() +
                                                             "_cheese")
        if not self.cheese_img.is_cached():
            base_img = Screen.get_instance().create_empty_image(True)
            self.cheese_img.load_surface(base_img.img)
            surf_text = Screen.create_text(
                Strings.get("Cheese"), ResourceManager.get(Config.get("font")),
                100, Config.get("text_color"))
            tw, th = surf_text.get_size()
            bw, bh = self.cheese_img.img.get_size()
            self.cheese_img.img.blit(surf_text, ((bw - tw) / 2, (bh - th) / 2))
            self.cheese_img.save()

        self.wait_img = Screen.get_instance().create_image(self.get_name() +
                                                           "_wait")
        if not self.wait_img.is_cached():
            img = Screen.create_button(ResourceManager.get("empty.png"),
                                       Strings.get("Please wait..."),
                                       Config.get("text_color"),
                                       ResourceManager.get(Config.get("font")),
                                       100)
            self.wait_img.load_surface(img)
            self.wait_img.save()

        self.imgs = []
        wait_before = Config.get("wait_before_snap")
        for i in xrange(wait_before, 0, -1):
            cache_img = Screen.get_instance().create_image(
                "%s_%d" % (self.get_name(), i), True)
            if not cache_img.is_cached():
                base_img = Screen.get_instance().create_empty_image(True)
                cache_img.load_surface(base_img.img)

                img = Screen.create_text(str(i), None, 200, (255, 0, 0))
                iw, ih = img.get_size()
                w, h = base_img.size

                cache_img.img.blit(img, (10, 10))
                cache_img.img.blit(img, (w - iw - 10, 10))
                cache_img.img.blit(img, (10, h - ih - 10))
                cache_img.img.blit(img, (w - iw - 10, h - ih - 10))

                cache_img.save()
            self.imgs.append(cache_img)

        Screen.get_instance().register_callback("on_preview_starts",
                                                self._on_preview_starts)
Exemplo n.º 3
0
def create_action_button(button_id, text, img):
    button_font = Config.get("buttons")["font"]
    button_font_size = Config.get("buttons")["font_size"]
    button_img = Config.get("buttons")["img"]
    button_margin = Config.get("button_margin")
    button_text_color = Config.get("buttons")["text_color"]

    button = Screen.create_button(ResourceManager.get(button_img), text,
                                  button_text_color,
                                  ResourceManager.get(button_font),
                                  button_font_size)

    w, h = img.get_size()
    bw, bh = button.get_size()
    if button_id == Arduino.BUTTON_1:
        img.blit(button, (w - (bw + button_margin), h - (bh + button_margin)))
    elif button_id == Arduino.BUTTON_2:
        img.blit(button, (button_margin, h - (bh + button_margin)))