2025, Nov 27 11:00
Unexpected Pygame window in Thonny? How to turn off Pygame Zero mode for plain scripts
Seeing a Pygame window when running simple scripts in Thonny? It's Pygame Zero mode. Disable it in Run menu to get console output only, without the extra screen.
Thonny shows a Pygame window for plain scripts: how to turn it off
If you run a simple Python script in Thonny and a Pygame window pops up instead of just printing to the shell, you’ve likely hit an IDE setting rather than a code issue. Here’s how to recognize what’s going on and fix it in seconds.
Consider a minimal script that should only print text to the console.
msg = "Hello from Thonny"
print(msg)
When executing such code, you expect to see only the printed output. If a Pygame screen appears alongside, the behavior isn’t coming from your script logic.
What’s causing the unexpected Pygame window
This effect is triggered by Pygame Zero mode being turned on in Thonny. With this mode enabled, Thonny starts a Pygame screen even when you run ordinary Python code, which explains why the extra window appears.
Fix: disable Pygame Zero mode in Thonny
Open the Run menu and uncheck "Pygame Zero mode". Once this option is disabled, the extra screen will no longer appear and your script will behave as expected.
After switching the mode off, the same script will produce only console output. For reference, here’s an equivalent snippet:
text_line = "Hello from Thonny"
print(text_line)
Why this detail matters
Understanding that the behavior is tied to an IDE mode, not your code, saves time on pointless debugging. Disabling the mode prevents visual noise during runs and ensures you see only the output you intend to generate.
Wrap-up
If a blank Pygame window shows up while running non-Pygame scripts in Thonny, check Run → "Pygame Zero mode" and turn it off. Keep it disabled for standard scripts and enable it only when you actually need Pygame Zero behavior.