<div dir="ltr">A little bit of context/code might help, at least to understand why do you need to run that code and display the output *after* the dialog is shown, and why do you need to do that when the dialog is shown. Also, it is not clear if the code you run takes a lot of time/resources, which might or might not block the UI.<div><br>Anyway, in similar cases (when I need to actually show the dialog and do something on/with the interface) I prefer to implement the exec_() method and return the actual exec_() class method at the end.</div><div>In this way I don't need to mess around with modality, results and so on, leaving the behavior almost intact. Also, you can set custom arguments to your exec_() implementation, which might come handy.</div><div><br></div><div><font face="monospace, monospace">class MyDialog(QtWidgets.QDialog):</font></div><div><font face="monospace, monospace">    ...</font></div><div><font face="monospace, monospace">    def exec_(self):</font></div><div><font face="monospace, monospace">        self.show()</font></div><div><font face="monospace, monospace">        data = self.someMethod(someArgument)</font></div><div><font face="monospace, monospace">        ...</font></div><div><font face="monospace, monospace">        self.myTextEdit.setPlainText(processedData)</font></div><div><font face="monospace, monospace">        res = QtWidgets.QDialog.exec_(self)</font></div><div><font face="monospace, monospace">        if res:</font></div><div><font face="monospace, monospace">            #you can do something with the result of the exec_()</font></div><div><font face="monospace, monospace">            if res == self.Yes:</font></div><div><font face="monospace, monospace">                self.doSomething()</font></div><div><font face="monospace, monospace">        return res</font></div><div><br></div><div>Obviously, if the code you need to run there requires too many resources, you might think about using a QObject moved to a new QThread and use custom signals to update the data.</div><div><br></div><div><br></div><div>Regards,</div><div>MaurizioB</div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-04-13 13:00 GMT+02:00 Starglider Developer <span dir="ltr"><<a href="mailto:starglider.dev@gmail.com" target="_blank">starglider.dev@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div>Hi,<br></div>I need after the QDialog is show, to run code and display the output to a QTextEdit.<br></div>Now I can only run the code with the QDialog with user input -a QPushButton-<br></div>If the code runs inside the<br><span style="font-family:monospace,monospace">def __init__(self, parent=None):</span><br><br>the QDialog is not shown until it finish the code execution.<br><br></div>I'm using Python 2.7 and PyQt4.<br><br></div>Thank you in advance.<br></div>
<br>______________________________<wbr>_________________<br>
PyQt mailing list    <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
<a href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt" rel="noreferrer" target="_blank">https://www.<wbr>riverbankcomputing.com/<wbr>mailman/listinfo/pyqt</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">È difficile avere una convinzione precisa quando si parla delle ragioni del cuore. - "Sostiene Pereira", Antonio Tabucchi<br><a href="http://www.jidesk.net" target="_blank">http://www.jidesk.net</a></div>
</div>