From 938eb372d9f52684847e4c02dcc69b2979ee4fc1 Mon Sep 17 00:00:00 2001 From: jacobwhiteman17 <54951159+jacobwhiteman17@users.noreply.github.com> Date: Wed, 7 Apr 2021 20:39:56 -0400 Subject: [PATCH] Update preview.py, fix issue #575 Fixed issue #575. Added two pg.quit statements at lines 146 and 162. For line 146, this statement adds quit functionality for " event.type == pg.KEYDOWN and event.key == pg.K_ESCAPE". This allows the window to close whenever the event triggers. For line 162, once the for loop ends (the video ends), the window closes instead of crashing. --- moviepy/video/io/preview.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/moviepy/video/io/preview.py b/moviepy/video/io/preview.py index f59be90ee..0dee54fa1 100644 --- a/moviepy/video/io/preview.py +++ b/moviepy/video/io/preview.py @@ -143,6 +143,7 @@ def preview( if audio: video_flag.clear() print("Interrupt") + pg.quit() return result elif event.type == pg.MOUSEBUTTONDOWN: @@ -157,3 +158,5 @@ def preview( t1 = time.time() time.sleep(max(0, t - (t1 - t0))) imdisplay(img, screen) + + pg.quit()