<HTML>
<HEAD>
<TITLE>Re: [PyQt] QCoreApplication::exec: The event loop is already running</TITLE>
</HEAD>
<BODY>
<FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>When you start another mainwindow (or top level widget for that matter) you don’t need to call exec_ or make another QApplication.<BR>
<BR>
The way I normally import things like this is the following:<BR>
<BR>
Foo.py<BR>
<BR>
class MainWindow()...<BR>
...<BR>
<BR>
def Start():<BR>
m = MainWindow()<BR>
m.show()<BR>
<BR>
if __name__ == “__main__”:<BR>
import sys<BR>
app = QApplication(sys.argv)<BR>
Start()<BR>
app.exec_()<BR>
<BR>
<BR>
To start the application from the command line,<BR>
<BR>
python Foo.py<BR>
<BR>
And to load it from another modele, Bar.<BR>
<BR>
import Foo<BR>
Foo.Start()<BR>
<BR>
Brian<BR>
<BR>
On 3/2/09 1:38 PM, "Brent Villalobos" <<a href="Brent.Villalobos@pdi.dreamworks.com">Brent.Villalobos@pdi.dreamworks.com</a>> wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>I have a pyqt application that imports and runs another pyqt<BR>
application. I am not launching the second application in its own<BR>
process, but I'm just relying on python's module importing<BR>
architecture. Both applications seems to run fine without any problems,<BR>
but I'm seeing this warning message:<BR>
QCoreApplication::exec: The event loop is already running<BR>
<BR>
While everything seems to run fine I feel like I'm doing something wrong<BR>
and I will eventually be bitten by some odd side effect. Are these<BR>
fears warranted? I know that the Qt documentation says that you should<BR>
only have one QApplication instance so is this just warning and Qt is<BR>
doing the right thing "under the hood?"<BR>
<BR>
If this will create problems, can you provide some suggestions on what I<BR>
should do differently? I want to avoid launching a second process if<BR>
possible. Is it possible for one QApplication instance to manage<BR>
multiple gui applications without problems?<BR>
<BR>
Finally, if there is no problem is there a way I can suppress that<BR>
warning so that users don't freak out? Thanks.<BR>
-Brent<BR>
_______________________________________________<BR>
PyQt mailing list <a href="PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><BR>
<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><BR>
<BR>
</SPAN></FONT></BLOCKQUOTE>
</BODY>
</HTML>