tags:

views:

30

answers:

1

I have an application that has a PyQT GUI. I set up the GUI in the usual PyQT fashion:

app = QtGui.QApplication(sys.argv)
win = MainWindow()
win.initialize()
win.show()
sys.exit(app.exec_())

The problem is that right after this I have a while loop that handles signals (signal.signal(signal.SIGINT, ...) and also does some other things. If I call sys.exit(app.exec_()) before the while loop, the loop does not execute. If I call it after the loop, the GUI hangs up. Any help is much appreciated!!

+1  A: 

The app.exec_() call basically starts 'a while loop that handles [QT] signals' etc. It's the event loop of the program.

You shouldn't need your own loop to do that stuff. If you do, you're talking about multiple threads and you need to look at the docs for QThread and/or QEventLoop.

You really shouldn't need a while loop to handle system signals like SIGINT etc - these are specifically designed so that you 'hook into' them like events, and their occurrence will trigger a function you specify.

sje397