[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] Display a QDialog when a QThread start
From:       FERREC Romain <romain () elgeekador ! tk>
Date:       2017-09-13 9:33:01
Message-ID: 3745951.vpmXGUVM77 () optiplex
[Download RAW message or body]

Hello,

I use PyQt5 and I'm trying to display a loading window when a QThread is 
running. You can find a part of my actual code in attachment.

Each time, the Qdialog is displayed once the QThread is finished, but if I put 
the line 11 before all the signals connections, it works (sometimes I have an 
output : "QThread::wait: Thread tried to wait on itself", I don't know why). 
However it is not a good way to do it.

Here is what I have on my screen : https://gifyu.com/images/
vokoscreen-2017-09-13_09-34-55.gif (don't take care about the numbers in 
output).

Thanks you in advance.






["script.py" (script.py)]

#main windows
    def _update_ctrl(self):
        """ Contrôleur de mise de à jour de la liste des proxies dans le
        tableau
        """
        pu = dialogs.ProxiesUpdater(self)
        pf = ProxyFetcher()
        pf.started.connect(pu.show)
        pf.finished.connect(pu.hide)
        pf.new_proxies.connect(self._set_table)
        pf.start()

# threads.py
class ProxyFetcher(QtCore.QThread):
    """ Tâche recuperant les proxies disponibles sur l'ensemble des
    fournisseurs
    """

    new_proxies = QtCore.pyqtSignal(object)

    def __init__(self):
        QtCore.QThread.__init__(self)
        self._init_providers()

    def __del__(self):
        self.wait()

    def _init_providers(self):
        self._providers = []
        for name, cls in inspect.getmembers(providers):
            if inspect.isclass(cls) and cls.__module__ == "models.providers":
                self._providers.append(cls())

    def run(self):
        for provider in self._providers:
            self.new_proxies.emit(provider.get_proxies())


[Attachment #4 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic