I am trying to run a simple Hello world example. After running and closing the GUI window the first time, the code does not work the 2nd time. It appears that the previous instance is not complete. Any ideas what needs to be done to overcome this? (I am using Spyder)
from PyQt5.QtWidgets import *
app = QApplication([])
label = QLabel('Hello World!')
label.show()
app.exec_()
Try this ? I had a similar problem in a loop
app = QApplication.instance()
if app is None:
app = QApplication([])
try this
from PyQt5.QtWidgets import QLabel, QApplication
import sys
app = QApplication([])
label = QLabel('Hello World!')
label.show()
sys.exit(app.exec_())
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.