PyQt5 start an app several times from different threads

0

I'm trying to load an app in Qt that runs from Python, the app only contains a QWebView to show a web page and it has to be able to run several times and from different threads (not at the same time) my code is this:

# -*- coding: utf-8 -*-
from PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebKitWidgets import QWebView
from threading import Thread


def start():
    app = QApplication([])
    view = QWebView()
    view.show()
    view.load(QUrl('http://www.google.es'))
    app.exec_()
    del app


print '#1'
t = Thread(target=start)
t.start()
t.join()

print '#2'
t = Thread(target=start)
t.start()
t.join()

The fact is that the first time it opens correctly, but the others either directly stops Python or opens but the page does not show well

The application is a plugin for Kodi, and (it seems) every time the plugin runs it does so on a thread.

    
asked by divadr 08.04.2018 в 21:43
source

0 answers