实际上我试着做一个html页面的显示器。我有一些html的列表,我需要显示,每个页面必须保持可见,而x秒。 但是,在显示第一个页面之后,应用程序崩溃,pythonshell重新启动。你知道吗
在我看来,我会创建一个窗口来显示页面并关闭应用程序,因为之后我会尝试显示png/jpg,所以我需要关闭应用程序来使用Pygame图片,然后重新构建应用程序来显示html页面。 我要找的清单: html页/html页/picture/html页/picture/picture
因此,我构建了一个示例代码来测试显示器:
from PyQt5 import QtWidgets, QtWebEngineWidgets, QtCore
import sys
continuer = True
while continuer:
print("Application created")
# Create application
app = QtWidgets.QApplication(sys.argv)
# Add window
win = QtWidgets.QWidget()
win.setWindowTitle('My first rendering')
# Add layout
layout = QtWidgets.QVBoxLayout()
win.setLayout(layout)
# Create QWebView
view = QtWebEngineWidgets.QWebEngineView()
view.setUrl(QtCore.QUrl('https://google.com'))
# Add QWebView to the layout
layout.addWidget(view)
# Show window, run app
win.show()
QtCore.QTimer.singleShot(7*1000, win.close)
QtCore.QTimer.singleShot(7*1000, app.quit)
print("View displayed")
# While loop
app.exec_()
print('Close Application')
print("End While Loop")
执行后的结果
可能是系统argv在应用程序var中,这是一个错误,但我是Python新手,所以我不知道如何解决这个问题。你知道吗
问题是QApplication不一定被消除,因此您将创建多个QApplication Qt禁止的,更好的解决方案是重新考虑它,验证如果它不存在,那么创建一个新的QApplication:
相关问题 更多 >
编程相关推荐