Hi all,

I have 2 form and a main.py in the project: ffrend.py and fmain.py

main.py:

from PyQt4 import QtCore, QtGui
from fmain import *

if __name__ == "__main__":
    import sys
    app = QtGui.QApplication(sys.argv)
    MainWindow = QtGui.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    app.exec_()

fmain.py (there is a button to execute the following function)

def friendNetWork(self):
        form = QtGui.QWidget()
        ui = Ui_ffriend()
        ui.setupUi(form)
        form.show()
        app.exec_()

When I run main.py, the fmain form is shown. When I click the button on fmain form, the friendNetWork will be executed and create another widget.

But...I received the error in console :(...And the python is hang :(

QCoreApplication::exec: The event loop is already running
QCoreApplication::exec: The event loop is already running
QCoreApplication::exec: The event loop is already running
QCoreApplication::exec: The event loop is already running

Please help me with this

Re: Need help with PyQT: The event loop is already running 80 80

the line
app.exec_()
starts the event loop and you have two of those lines

Re: Need help with PyQT: The event loop is already running 80 80

Actually, I tried to remove app.exec_() in the friendNetWork function.

But this made the ffriend display and exit immediately.

Re: Need help with PyQT: The event loop is already running 80 80

see this thread. It looks like the same issue.

Re: Need help with PyQT: The event loop is already running 80 80

Hi Gribouillis,

Thanks for your reply.

I changed my solution a litte bit:

  • Create a reference for ffriend in fmain
  • Remove app.exec_() in ffriend

Now the ffriend can be displayed without app.exec_().

But another problem occured, I can't interact with ffriend. There is a button on ffriend will do something as printing a message. Now, I clicked the button but nothing printed :'(

def setupUi(self, ffriend):
    ### Code generated from Pyuic
    ...
    self.btnphantich = QtGui.QPushButton(ffriend)
    ...
    QtCore.QObject.connect(self.btnphantich, QtCore.SIGNAL(_fromUtf8("clicked()")), self.printhello)
    QtCore.QMetaObject.connectSlotsByName(ffriend)

def printhello(self):
    print "hello world!" ### No hello world here although it can be printed with app.exec_()

Please gui me or point me what to read next.

Thank you!

Re: Need help with PyQT: The event loop is already running 80 80

Please help me. I attached the source here:
https://code.google.com/p/silverwolf-projects/source/browse/trunk/fmain.py
https://code.google.com/p/silverwolf-projects/source/browse/trunk/fpersonal.py
https://code.google.com/p/silverwolf-projects/source/browse/trunk/main.py

Run the main.py, after that click on the menu Analyze, then a widget is openned. Click the button on that widget, no thing shown :'(
55f19a8865402d316565a11fafd71693
fdf6fe2d5d8f09000c530c7485802eba

Re: Need help with PyQT: The event loop is already running 80 80

Guys, I am facing same issue, help me how you resolve this topic?

commented: See above solution for this problem. +0
Re: Need help with PyQT: The event loop is already running 80 80

I have the same problem , please help D:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.