How to translate Python console program (including while true loop) to PyQt?
<p>I have a Python console program that I want to transfer to a GUI.
I thought of using PyQt 5, but I'm open to alternatives.</p>

<p>The simplified console code looks like this:</p>

<pre><code>while True:
   data = obtain_data_from_device(source)
   print(datatotext(data))
</code></pre>

<p>Now from what I understand, GUI code works different.
But how do I continuously update a text box in PyQt using the obtain_data_from_device function which might take any time from 0.5 to 30 seconds?</p>

<p>A while loop can't do it, as it screws up the GUI, a timer doesn't work, as the duration is variable.</p>

<p>I'd appreciate any hints.</p>

<p>One option, since you already have a working program that writes to STDOUT, is to let the GUI program run the console program as a child process using <code>QProcess</code>.</p>

<p>The child will run asynchronously under control of the GUI program and the GUI program will receive the child's output via signals, i.e. non-blocking</p>

python qt pyqt