Skip to content
Search

Pygame.event

lastmod 2025-02-11created 2024-06-123 edits

Description of the Events used in Pygame.

WINDOWRESIZED vs WINDOWSIZECHANGED

Each is an event that occurs when the window size changes. However, the two events differ slightly, and it is important to understand this.

WINDOWRESIZED
Meaning - An event that occurs when the window size actually changes.
Use case - This event is generally called after the window size change is finalized, that is, when the user has finished resizing the window.
Features
  • Mainly used to perform tasks such as rearranging the layout or redrawing graphics when the window size has changed.
  • In tasks such as animations or layout changes, it may be called multiple times while the user is resizing the window.
WINDOWSIZECHANGED
Meaning - An event that occurs when a window size change starts or while it is in progress.
Use case - Used when you need to respond to the window size in real time while a window size change starts or is in progress.
Features
  • May be called multiple times before the window resizing finishes.
  • Generally used in situations where UI elements or the layout need to be adjusted in real time during resizing.

Key differences:

  • WINDOWRESIZED occurs after the window resizing is complete, whereas WINDOWSIZECHANGED can occur while the window resizing is in progress.
  • WINDOWRESIZED may be called only once, but </code>WINDOWSIZECHANGED</code> can be called multiple times while the window is being resized.

Understanding the difference between the two events and using them appropriately lets you provide a smoother user experience when resizing windows.

See also

author Zer0 sitemap