From: W. eWatson on
I I have a very simple program running in Python, with say the last
line print "bye". it finishes leaving the script showing >>> in the
shell window. The program proceeds linearly to the bottom line.

Suppose now I have instead a few lines of MatPlotLib code (MPL) like
this at the end:


Show displays some graph and again the code proceeds linearly from line
1. However, if one closes the graphic by clicking the x in the upper
right corner of that window, then no >>> appears in the shell, and one
must kill the shell using the x in the shell's upper right corner. A
little dialog with the choices of OK (kill) or cancel appears. Use OK
and the shell window disappears. A ctrl-c does nothing in the shell.

I know about sys.exit(),and a "finish" def when using Tkinter. I'm not
using Tkinter as far as I know via MPL.

So how does one exit smoothly in this case of Show(), so that the shell
window remains ready to entry commands?