diff --git a/clicker.png b/clicker.png new file mode 100644 index 0000000..4470c60 Binary files /dev/null and b/clicker.png differ diff --git a/clicker.svg b/clicker.svg new file mode 100644 index 0000000..771028f --- /dev/null +++ b/clicker.svg @@ -0,0 +1,64 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/photoboite.py b/photoboite.py index e3f925d..0e55741 100755 --- a/photoboite.py +++ b/photoboite.py @@ -81,10 +81,10 @@ class CaptureButton(Button): countdown = 3 def __init__(self, size, topleft, photoboite): - self.up_image = pygame.image.load('button-up.png').convert_alpha() + self.up_image = pygame.image.load(os.path.dirname(os.path.realpath(__file__)) + '/button-up.png').convert_alpha() self.up_image = pygame.transform.smoothscale(self.up_image, (size, size)) - self.down_image = pygame.image.load('button-down.png').convert_alpha() + self.down_image = pygame.image.load(os.path.dirname(os.path.realpath(__file__)) + '/button-down.png').convert_alpha() self.down_image = pygame.transform.smoothscale(self.down_image, (size, size)) rect = self.up_image.get_rect() @@ -103,7 +103,7 @@ class CaptureButton(Button): self.font = pygame.font.Font(None, 80) - self.photo_film = pygame.image.load('film.png').convert_alpha() + self.photo_film = pygame.image.load(os.path.dirname(os.path.realpath(__file__)) + '/film.png').convert_alpha() def draw_on(self, screen): if self.enabled: @@ -177,18 +177,24 @@ class Photo: self.uid = uid def take(self, camera): - self.name = "%s-%04d-%04d" % (time.strftime('%Y%m%d-%H%M%S'), self.cid, self.uid) + self.name = "photos/%s-%04d-%04d" % (time.strftime('%Y%m%d-%H%M%S'), self.cid, self.uid) self.capture = pygame.transform.smoothscale(pygame.image.load(camera.take(self.name)), (638, 480)) return self class SleepMode: - def __init__(self, seconds): + def __init__(self, seconds, screen): self.enabled = True self.drawn = False self.seconds = seconds + self.screen = screen + + self.clicker = pygame.image.load(os.path.dirname(os.path.realpath(__file__)) + '/clicker.png').convert_alpha() + self.clicker_rect = self.clicker.get_rect() + self.clicker_rect.topleft = ((self.screen.get_width() - self.clicker_rect.width) / 2, (self.screen.get_height() - self.clicker_rect.height) / 2) + def move(self): self.last_action = time.time() @@ -198,9 +204,10 @@ class SleepMode: self.move() self.enabled = False - def draw_on(self, screen): + def draw(self): if not self.drawn: - screen.fill((255,255,255)) + self.screen.fill((255,255,255)) + self.screen.blit(self.clicker, self.clicker_rect) pygame.display.flip() self.drawn = True @@ -228,7 +235,7 @@ class Photoboite: self.clock = pygame.time.Clock() - self.sleep = SleepMode(30) + self.sleep = SleepMode(30, self.screen) def screen(self): @@ -283,7 +290,7 @@ class Photoboite: while True: if self.sleep.enabled: self.sleep.event() - self.sleep.draw_on(self.screen) + self.sleep.draw() self.clock.tick(60) else: self.event()