How to close all windows with a gun (including from the previous script)?

So, I have python code that contains several graphs using pyplot. Each time I run the script, new chart windows appear, which I have to close manually. How to close all open windows for the gun at the beginning of the script? I.e. closing windows that were opened during previous executions of the script?

In MatLab, this can be done simply by using closeall .

+6
source share
2 answers

To close all open numbers from a script, you can call

 plt.close('all') 

or you can complete the associated Python process.

+3
source

In * nix mode, you can use the killall command.

killall app

closes each instance of the window with an application for the window name. You can also use the same command from your python script.
You can use os.system("bashcommand") to run bashcommand.

-2
source

All Articles