Skip to content

Commit

Permalink
Make the message 'camera not found' and 'Click the Load Image Button'…
Browse files Browse the repository at this point in the history
… in failure of getting file path more meaningful
  • Loading branch information
srevinsaju committed Dec 20, 2019
1 parent cfd961a commit 89551c8
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions puntillism.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@ def run(self):

# define some colors for not cam found
font = pygame.font.Font('freesansbold.ttf', 32)
text = font.render(_('Camera not found'), True, (255, 255, 255), (0, 0, 0))
text_frame = text.get_rect()
text_frame.center = (x_s // 2, y_s // 2)
message = _('Camera not found')


if not self.has_camera:
print("LOG: No /dev/video0 found")
Expand All @@ -116,7 +115,7 @@ def run(self):

if self.load_image_loop:
self.image_load_handler(screen, frames,
x_s, y_s, clock, text, text_frame)
x_s, y_s, clock, message, font)

# Destroy image load events
try:
Expand Down Expand Up @@ -162,7 +161,7 @@ def read_events(self, events, screen):
if event.key == pygame.K_ESCAPE:
self.running = False
self.load_image_loop = False

elif event.key == pygame.K_s:
self.parent.save_image(screen)

Expand Down Expand Up @@ -192,14 +191,22 @@ def read_events(self, events, screen):
print("warning : ", e)
self.running = True

def image_load_handler(self, screen, frames, x_s, y_s, clock, text, text_frame):
def image_load_handler(self, screen, frames, x_s, y_s, clock, message, font):
screen.fill((0, 0, 0))
pygame.display.update()

if not self.has_camera:
text = font.render(message, True, (255, 255, 255), (0, 0, 0))
text_frame = text.get_rect()
text_frame.center = (x_s // 2, y_s // 2)
else:
text = font.render(_("Click the Load Image Button"), True, (255, 255, 255), (0, 0, 0))
text_frame = text.get_rect()
text_frame.center = (x_s // 2, y_s // 2)

while self.load_image_loop:

if self.file_path is not None:

cad = pygame.image.load(self.file_path).convert()
cad = pygame.transform.scale(cad, (640, 480))
rect = []
Expand Down

0 comments on commit 89551c8

Please sign in to comment.