从代码来看,错误是由于第102行引起的。在此位置,在加载模块时,您将创建一个
QWidget(更精确地是一个
QMainWindow)。而这种情况发生
之前 的
QApplication创建。
另外,我也不知道为什么在这里有这个起始变量,因为它似乎没有被使用。
如果要使用
HelloBegin对象创建它,请在
__init__方法中移动它。
编辑:
如果要在模块加载时显示启动屏幕,则需要由一个小型,轻量级的模块启动该应用程序。在本模块中,您将:
- 创建QApplication
- 打开初始屏幕/消息框
- 然后才加载其他模块
为了使一切顺利进行,我将在一个单独的函数中导入模块,并使用一个小技巧来确保仅在GUI准备好后才能启动。该代码将如下所示:
from PyQt4.QtGui import QApplicationfrom PyQt4.QtCore import QTimerdef startApp(): import m1 import m2 wnd = createWindow() wnd.show()import sysapp = QApplication(sys.argv)splash = createSplashScreen()splash.show()QTimer.singleShot(1, startApp) # call startApp only after the GUI is readysys.exit(app.exec_())
createSplashScreen创建启动画面的功能在哪里
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)