Thanks Zoltan.. It did help a lot.. But if i want to capture single click and double click events of the mouse separately i'm afraid this can't be used..<br><br>def onTrayIconActivated(self, reason):<br> if reason == QSystemTrayIcon.DoubleClick:<br>
print('tray icon double clicked')<br> <br> if reason == QSystemTrayIcon.Trigger:<br> print("Tray icon single clicked")<br><br>If i double click the tray icon it executes both if conditions. Any way of resolving this?. Thanks again..<br>
<br><div class="gmail_quote">On Tue, Nov 9, 2010 at 11:27 AM, <span dir="ltr"><<a href="mailto:pyqt-request@riverbankcomputing.com">pyqt-request@riverbankcomputing.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
'activated' is a signal of QSystemTrayIcon.<br>
you have to connect it to a slot (the onTrayIconActivated method in this<br>
case) in order to catch it.<br>
i highly suggest this reading before step forward:<br>
<a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/pyqt4ref.html#new-style-signal-and-slot-support" target="_blank">http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/pyqt4ref.html#new-style-signal-and-slot-support</a><br>
<br>
minimal working example here:<br>
<br>
import sys<br>
from PyQt4.QtCore import *<br>
from PyQt4.QtGui import *<br>
<br>
class MainWindow(QMainWindow):<br>
<br>
def __init__(self, parent=None):<br>
super(MainWindow, self).__init__(parent)<br>
<br>
self.trayIcon = QSystemTrayIcon(self)<br>
self.trayIcon.activated.connect(self.onTrayIconActivated)<br>
self.trayIcon.show()<br>
<br>
def onTrayIconActivated(self, reason):<br>
if reason == QSystemTrayIcon.DoubleClick:<br>
print 'tray icon double clicked'<br>
<br>
if __name__ == "__main__":<br>
app = QApplication(sys.argv)<br>
w = MainWindow()<br>
w.show()<br>
sys.exit(app.exec_())<br>
<br>
<br>
hope it helps<br>
<br>
bests<br>
Zoltan<br>
<br>
<br>
<br>
On 2010.11.08. 15:54, Jebagnana Das wrote:<br>
> Hello all,<br>
><br>
> Based on this example<br>
> <a href="http://www.saltycrane.com/blog/2008/01/how-to-capture-tab-key-press-event-with/" target="_blank">http://www.saltycrane.com/blog/2008/01/how-to-capture-tab-key-press-event-with/</a><br>
> i've created a class as below<br>
><br>
> class SystemTrayIcon(QtGui.QSystemTrayIcon):<br>
><br>
> def __init__(self,parent,objectName):<br>
><br>
> QtGui.QSystemTrayIcon.__init__(self,parent)<br>
><br>
> self.setObjectName(objectName)<br>
><br>
> print("Tray icon created")<br>
><br>
> def activated(self,reason):<br>
><br>
> if reason==QtGui.QSystemTrayIcon.DoubleClick:<br>
><br>
> print("Tray icon Double clicked")<br>
><br>
> After creating an object for this class when i double click the tray<br>
> icon nothing happens. Any idea of what am i missing here?? Thanks..<br>
><br>
><br>
> _______________________________________________<br>
> PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com">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>
<br></blockquote></div>