Python
matplotlib: no window
The problem
No window is opened when a script is run from a command line. Running the script in an interactive IDE is fine.
What happens
The module matplotlib closes all windows when unloaded. This happens immediately after the script terminates if it is run from a command line. When run inside a IDE, then the module stays loaded, keeping windows opened.
How to fix
A quick solution is wait for an input from a user at the end of the script. The following code, when added at the end of the script, opens an extra window asking to press any key:
The function waitforbuttonpress() waits for a mouse click or a key being pressed and returns respectively False or True. The loop makes it sure that the program exists only in the second situation, so that you can interact with the windows using your mouse.
Note: the program stops only when a key is pressed while the extra window is active. This allows to interact with other windows without limitation.
