Quick answer: Pygame window icon looking pixelated in taskbar / dock? The OS may use a different size than your supplied surface and scale poorly. Provide a high-resolution source.

A 16x16 icon supplied via set_icon looks crisp at desktop size but pixelated on Windows 11’s 32x32 taskbar.

Use Larger Source

Pass a 256x256 or higher surface to set_icon. SDL scales down for each OS-needed size; better than upscaling small.

Platform Icon Sizes

Windows uses up to 256x256 in places. macOS uses 1024x1024 for Dock at retina. Linux varies. Provide oversized; OS picks.

Set Icon Before set_mode

icon = pygame.image.load("icon.png")
pygame.display.set_icon(icon)
screen = pygame.display.set_mode(size)

Setting icon after set_mode works on some platforms; before is more reliable across all.

Window vs Taskbar Icon

On Windows, the .ico in the executable controls some places (taskbar after launch, Start Menu). set_icon controls the window itself. Use pyinstaller / py2exe to embed .ico for cross-place consistency.

Verifying

Icon renders crisply at all OS scales. Taskbar, window title bar, alt-tab thumbnail all look right.

“Provide a large icon. OS scales down better than up.”

Ship icons at 256, 128, 48, 32, 16 — even if set_icon only uses one, the .ico embedded in the executable can use the rest.