So this is just me experimenting...
Anyway, there a peculiar error without the if block at 69 LOC. If you keep everything but just remove the if condition + the time.sleep, then proceed to decrement/increment the variable "width" using the tkinter buttons "Up" and "Down" fast enough (I used two fingers because there no key repetitoon support on the tkinter function I made), you get this:
Process finished with exit code -1073740791 (0xC0000409)
After a while, I found that the likely cause is one of the variable/memory part of pygame/tkinter that try to access something that isn't likely there, or not "ready" yet? (eg: not initialized, etc). But on retrospect, I probably don't know the exact cause. Here an example I found on stackoverflow: https://stackoverflow.com/questions/50562192/process-finished-with-exit-code-1073740791-0xc0000409-pycharm-error