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).
使用matplotlib的我的PyQt应用程序第一次加载需要几秒钟,即使在快速机器上也是如此(第二次加载时间要短得多,因为Windows会将这些DLL保存在内存中)。
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?
我想知道在加载matplotlib库时显示启动画面是否可行。实际加载发生在哪里 - 是否执行from行?如果是这样,如何在启动屏幕中执行此行并仍然能够在整个代码中使用该模块?
A related dilemma is how to test this - can I ask Windows to load the DLLs for every execution and not cache them?
一个相关的困境是如何测试这个 - 我可以要求Windows为每次执行加载DLL而不是缓存它们吗?
1 个解决方案
#1
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.
是的,加载模块发生在import语句所在的行。如果您在此之前创建QApplication并显示启动画面,则应该能够执行所需的操作 - 每当需要使用启动画面更新新消息时,您还需要调用QApplication.processEvents()。
#1
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.
是的,加载模块发生在import语句所在的行。如果您在此之前创建QApplication并显示启动画面,则应该能够执行所需的操作 - 每当需要使用启动画面更新新消息时,您还需要调用QApplication.processEvents()。