[PyQt] Show QDialog and execute code after
Barry Scott
barry at barrys-emacs.org
Sun Apr 15 16:01:26 BST 2018
> On 15 Apr 2018, at 13:20, Kyle Altendorf <sda at fstab.net> wrote:
>
>
>
> On April 15, 2018 3:55:14 AM EDT, Barry <barry at barrys-emacs.org <mailto:barry at barrys-emacs.org>> wrote:
>>
>>
>>> On 14 Apr 2018, at 20:46, Ricardo Araoz <ricaraoz at gmail.com> wrote:
>>>
>>>> On 14/04/18 15:46, Kyle Altendorf wrote:
>>>> On April 14, 2018 2:01:36 PM EDT, Maurizio Berti
>> <maurizio.berti at gmail.com> wrote:
>>>>>> I making an update app that shows a QTextEdit object and starts
>>>>> (should)
>>>>> start to get information from the system before
>>>>>> ask the user what to do, it does that but if now but only after
>> the
>>>>> function get all the system info and the it draws the QDialog.
>>>>>> It's something like a Debian apt-get where the terminal is showing
>>>>> what
>>>>> is appending before and after each operation.
>>>>>
>>>>> If that's the case, you should use a separate QObject that collects
>> the
>>>>> output of apt-get and emits a signal every time it has something to
>>>>> show.
>>>>> That QObject has to be moved to a new QThread, so that the apt-get
>>>>> process
>>>>> will not block the GUI interaction and painting.
>>
>> Is there any advantage to using QThread over python threads?
>
> They get you an event loop in the thread (so long as you use them properly for that) which is required to receive signals (along with not blocking the event loop, just as you shouldn't in the main thread).
That is useful to know. I have always been sending signals from the background thread and not thought of going the other way.
>
> Mostly I look for options other than threads. There are various for various needs between Qt and Python. This includes async/inlineCallbacks functions which allow you to write async code without breaking it up and connecting with signals and slots which is a pain when sequencing stuff.
Threads has it drawbacks as does async. As with all things pick the best solution from your available design choices.
Barry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20180415/013825f4/attachment.html>
More information about the PyQt
mailing list