Why does pygame.display.update() not work if an input is directly followed after it?

Call pygame.event.pump() after pygame.display.update() and before input(''):

def main():
    pygame.draw.rect(screen,[235,235,235],(200,200,200,200))
    pygame.display.update()

    pygame.event.pump()

    input('')

At some OS, pygame.display.update() respectively pygame.display.flip() doesn’t update the display directly. It just invalidates the display and notifies the system to update the display. Actually the display is updated when the events are handled.
The events are either handled by either pygame.event.pump() or pygame.event.get() (Which is used in event loops, but would do the job as well). Note this instruction do not only handle the IO or user events, they handle a bunch of internal events too, which are required to run run the system.

Not all implementations on all OS behave the same. At some OS it is sufficient to call pygame.display.update(), that is the reason that not everyone at every system can reproduce the issue. But in this case it is never wrong to call pygame.event.pump().

Leave a Comment