From the code, the error is due to line 102. There, while the module is loaded, you create a QWidget
(more precisely a QMainWindow
). And this happens before the QApplication
is created.
Also, I don't know why you have this start variable there, as it doesn't seem to be used.
If you want to create it with the HelloBegin
object, move it in the __init__
method.
Edit:
If you want to display a splash screen while your modules are loading, you need the application to be started by a small, lightweight, module. In this module, you will:
- Create the QApplication
- Open your splash screen / message box
- Only then load the other modules
For everything to work smoothly, I would import the modules in a separate function, and use a small trick to make sure it's started only once the GUI is ready. The code will look like this:
from PyQt4.QtGui import QApplication
from PyQt4.QtCore import QTimer
def startApp():
import m1
import m2
wnd = createWindow()
wnd.show()
import sys
app = QApplication(sys.argv)
splash = createSplashScreen()
splash.show()
QTimer.singleShot(1, startApp) # call startApp only after the GUI is ready
sys.exit(app.exec_())
where createSplashScreen
is the function that creates your splash screen
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…