Python Forum
[PyGame] Waiting screen until user input - PiBooth
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] Waiting screen until user input - PiBooth
hey guys,

in advance: I'm new in PyGame.

I'm working on a photo booth / photo box with the software "PiBooth" -

It is possible to create your own plugins – hooks in different states. I created a plugin that displays a screen when the Photo Booth printer needs to be refilled:

When the print counter reaches the refill level (after 38 prints), a message should appear with a “Done” button or something similar.

My problem is: I don't know how to display the screen UNTIL user input.

Here the code:

def state_wait_do(win, app, events):
    #and app.print_ok != 0  and app.find_print_event(events).printer == 1
    if app.find_print_event(events) != None:"sate_print_do")

        printed = app.count.printed

        if((printed % 38) == 0):
            text = "Bitte Transferrolle wechseln und Papier auffuellen, 38 gedruckte Bilder.\n\nStatus Drucker:\n"
            sendstatusmail("Transferrolle wechseln und Papier auffuellen", text)
            win_rect = win.get_rect()
            text = "Bitte warten..."
            font = fonts.get_pygame_font(text, fonts.CURRENT,
                                    win_rect.width//1.5, win_rect.height//1.5)
            text_surface = font.render(text, True, win.text_color)
            if isinstance(win.bg_color, (tuple, list)):
                bg_surface = pictures.get_pygame_image(win.bg_color, win_rect.size, crop=True, color=None)
                win.surface.blit(bg_surface, (0, 0))
            win.surface.blit(text_surface, text_surface.get_rect(
            n = 0
            gef = False
            while True:
                if gef:
                events = pygame.event.get()
                n = n + 1
                m = 0
                for event in events:
                    print(str(n) + str(m))
                    if event.type == pygame.KEYDOWN:
                        gef = True
What is wrong with your code? The while loop should prevent anything changing the screen until the KEYDOWN event.

I think it makes more sense to connect to the PRINT plugin instead of the WAIT plugin.
It's not necessary, in my opinion, to compute every ray point. As each point is calculated, I would review it and halt when a collision is found. basket random
def illuminate_block(self, blocks, ray_point):
    """ Find first block that collides with ray_point,  Returns block or None """
    for block in blocks:
        if block[1].rect.collidepoint(ray_point):
            block[1].illuminated = True
            return block
    return None
def cast_rays(self):
    cx = self.rect.centerx
    cy = self.rect.centery
    blocks = []
    for b in
        b.illuminated = False
        # Cull the block list here so it doesn't have to happen for each ray point.
        if abs(b[0][0] - cx) < 200 and abs(b[0][1] - cy) < 200:
    for ray in range(0, 360, 20):
        # Do expensive sin and cos once per ray
        sin_ray = math.sin(ray)
        cos_ray = math.cos(ray)
        for depth in range(20, 100, 5):
            ray_point = (cx - sin_ray * depth, cy + cos_ray * depth)
            if self.illuminate_block(blocks, ray_point) is not None:
There are pygame routines that can do the task for you if they are sprites.

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGame] When I hit the space bar from the home screen, it sends me to the game over screen JesusisKing 1 1,104 Apr-30-2023, 10:11 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020