Why are you calling the exec_() function from inside the sys.exit() call?<div><br></div><div>From the way it's programmed, it looks like sys.exit() will execute and hold until it gets a result back from the MessageBox called inside the tray icon. At that point it's going to exit using the result as it's argument. </div>
<div><br></div><div>If you just select 'OK' then the MessageBox returns a 0, which will then cause a normal termination the program (exit code 0).</div><div><br></div><div><br><br><div class="gmail_quote">On Mon, Jan 12, 2009 at 10:29 AM, Tim Hoffmann <span dir="ltr"><<a href="mailto:tim.hoffmann@uni-bonn.de">tim.hoffmann@uni-bonn.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I write an application with a trayicon as main interface. When I popup a QMessageBox in a slot, the application terminates after closing the box. I have no idea why. Termination is regular (exit code 0 and no exception is raised). However, if I make the widget visible (uncommenting self.show() in example below), termination does not happen.<br>
<br>
I'm using Python 2.5 and Pyqt 4.4.3<br>
<br>
Thanks<br>
<br>
<br>
<br>
minimal example:<br>
----------------<br>
<br>
import sys<br>
from PyQt4 import QtCore, QtGui<br>
<br>
class Systray(QtGui.QWidget):<br>
def __init__(self):<br>
QtGui.QWidget.__init__(self)<br>
self.createActions()<br>
self.createTrayIcon()<br>
self.trayIcon.show()<br>
#self.show()<br>
<br>
def createActions(self):<br>
self.quitAction = QtGui.QAction(<a href="http://self.tr" target="_blank">self.tr</a>("&Quit"), self)<br>
QtCore.QObject.connect(self.quitAction, QtCore.SIGNAL("triggered()"),<br>
<br>
QtGui.qApp, QtCore.SLOT("quit()"))<br>
self.testAction = QtGui.QAction(<a href="http://self.tr" target="_blank">self.tr</a>("Test"), self)<br>
QtCore.QObject.connect(self.testAction, QtCore.SIGNAL("triggered()"), self.test)<br>
<br>
def createTrayIcon(self):<br>
self.trayIconMenu = QtGui.QMenu(self)<br>
self.trayIconMenu.addAction(self.quitAction)<br>
self.trayIconMenu.addAction(self.testAction)<br>
<br>
self.trayIcon = QtGui.QSystemTrayIcon(self)<br>
self.trayIcon.setIcon(QtGui.QIcon("test.png"))<br>
self.trayIcon.setContextMenu(self.trayIconMenu)<br>
<br>
def test(self):<br>
QtGui.QMessageBox.information(self, "title", "hello")<br>
# closing this terminates the program<br>
<br>
app = QtGui.QApplication(sys.argv)<br>
x = Systray()<br>
sys.exit(app.exec_())<br>
_______________________________________________<br>
PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a><br>
<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br>
</blockquote></div><br></div>