PyQt: splash screen while loading “heavy” libraries
-
22-08-2019 - |
Question
My PyQt application that uses matplotlib
takes several seconds to load for the first time, even on a fast machine (the second load time is much shorter as the DLLs are kept in memory by Windows).
I'm wondering whether it's feasible to show a splash screen while the matplotlib
library is being loaded. Where does the actual loading take place - is it when the from
line is executed? If so, how can I make this line execute during the splash screen and still be able to use the module throughout the code?
A related dilemma is how to test this - can I ask Windows to load the DLLs for every execution and not cache them?
Solution
Yes, loading the module takes place at the line where the import statement is. If you create your QApplication
and show your splash screen before that, you should be able to do what you want -- also you need to call QApplication.processEvents()
whenever you need the splash screen to update with a new message.