Open jah-mann opened 5 years ago
Other tests I have done:
1. Start my program > start console menu > make selections but do not plot anything > leave console menu > exit my program. ---- Result: No error message
2. Start my program > start console menu > make selections but do not plot anything > leave console menu > call script using Matplotlib directly from my code > exit my program. ---- Result: No error message.
So it seems as if the console menu and Matplotlib can each run at separate times within the same larger program and not have this issue. The issue only occurs when the console menu is currently running and Matplotlib is called within it.
Hello,
I am using the console menu package to create a menu of data analytics options, some of which call plotting functions (such as plotting histograms) with Matplotlib. I am able to call my functions and have the plots display correctly, but when I finally finish the entire program (after plotting, exiting the console menu, and exiting my program itself), I receive this error:
Upon looking into this and finding various questions asked in the past about this problem (such as this one), it appears that TKinter is used for Matplotlib when graphing things, and it is intended to be run on a single thread. So whenever I call Matplotlib from one of the FunctionItems in the console menu, it ends up causing this error at the end of the program. I can confirm that this does not happen when I call the function outside of the console menu framework.
Previous solutions to this problem seem to be centered around importing Matplotlib and then doing matplotlib.use('Agg'), but this makes the back-end non-GUI based, so the solution does not work for people who wish to graph in Matplotlib.
Could this have to do with the "import threading" statement in the console menu code? Here are some posts I found on potentially getting rid of this problem: Deleting the TCL interpreter Running GUI on Main Thread