My pygame window flickers

This is going to be a long one:

Yesterday I started a new pygame project. I have not used pygame for over a year. I was writing the basics of a new project I was going to work on (clock, screen, main loop). When I ran my program for the first time the window started flickering (see video below). Then I tested all my old projects and the same thing was happening. The window becomes unresponsive after trying to close it.

What I am running:

  • windows 11
  • vs code (idle shown in video)

Things I have tried:

  • Trying pygame on python version 3.10 and 3.11
  • reinstalling pygame
  • updating pygame
  • trying the same script on a different machine (it worked on their machine)
  • restarting my computer
  • running the program in idle

Things I have observed:

  • The flickering happens faster when I don't have a clock in my script
  • The speed of the flickering seems to differ from run to run
  • The error only happens on my machine

https://reddit.com/link/1cotzi2/video/pkm2monhpmzc1/player