PyQt:加载“重”时出现闪屏 图书馆
我使用 matplotlib 的 PyQt 应用程序首次加载需要几秒钟的时间,即使在快速机器上也是如此(第二次加载时间要短得多,因为 Windows 将 DLL 保留在内存中)。
我想知道在加载 matplotlib
库时显示启动屏幕是否可行。 实际加载发生在哪里 - 是在执行 from
行时吗? 如果是这样,我怎样才能使这一行在启动屏幕期间执行,并且仍然能够在整个代码中使用该模块?
一个相关的困境是如何测试这一点 - 我可以要求 Windows 在每次执行时加载 DLL 而不是缓存它们吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,加载模块发生在 import 语句所在的行。 如果您创建了
QApplication
并在此之前显示了启动屏幕,您应该能够执行您想要的操作 - 并且您需要在任何时候调用QApplication.processEvents()
需要用新消息更新启动屏幕。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 callQApplication.processEvents()
whenever you need the splash screen to update with a new message.