Skip to content

Commit

Permalink
Update preview.py, fix issue #575
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jacobwhiteman17 authored Apr 8, 2021
1 parent 5a63b64 commit 938eb37
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions moviepy/video/io/preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def preview(
if audio:
video_flag.clear()
print("Interrupt")
pg.quit()
return result

elif event.type == pg.MOUSEBUTTONDOWN:
Expand All @@ -157,3 +158,5 @@ def preview(
t1 = time.time()
time.sleep(max(0, t - (t1 - t0)))
imdisplay(img, screen)

pg.quit()

0 comments on commit 938eb37

Please sign in to comment.