In the middle of my script I ask the user to zoom a figure and call ginput afterwards. I would like to interrupt (return) the script if the user closes the figure. Right now I did
However this waits for the user to click a button even if the figure is closed. That is, the user closes the figure, but the script does not notice it until it ALSO press a button. The uiwait or waitfor command could understand if the figure is closed, but then I have to close the figure in order to make the script continue.
Is it possible to obtain a result similar to