[PyQt] Show QDialog and execute code after

Ricardo Araoz ricaraoz at gmail.com
Fri Apr 13 13:47:18 BST 2018


On 13/04/18 08:00, Starglider Developer wrote:
> Hi,
> I need after the QDialog is show, to run code and display the output 
> to a QTextEdit.
> Now I can only run the code with the QDialog with user input -a 
> QPushButton-
> If the code runs inside the
> def __init__(self, parent=None):
>
> the QDialog is not shown until it finish the code execution.
>
> I'm using Python 2.7 and PyQt4.
>
> Thank you in advance.
>

You might try putting the slow code inside a method, then in the 
__init__() method you instantiate your QTextEdit without data, then use 
QTimer.singleShot(0, self.yourSlowCode) inside which you'll be 
actualizing the QTextEdit as you have the data available. I think the 
singleShot will execute yourSlowCode() as soon as the window's event 
queue is processed, that means the widget will appear in the screen and 
take user input. Worth a try.
Check : http://doc.qt.io/qt-5/qtimer.html look for "special case" inside 
the "Detailed Description".



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20180413/2b058dbc/attachment.html>


More information about the PyQt mailing list