[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] Problems with QSystemTrayIcon
From:       Philippe Fremy <phil () freehackers ! org>
Date:       2009-02-19 10:58:29
Message-ID: 499D3B55.4010709 () freehackers ! org
[Download RAW message or body]

Hi,

I am having problem to get QSystemTrayIcon to work. I am running on
windows XP and I never see any notification messages.

My setup: windows XP, PyQt 4.3.3, python 2.5

See my attached simplified code, that runs standalone. Any idea what I
could be doing wrong ?

cheers,

Philippe



["croquemonster.png" (image/png)]
["example_qsystemtray.py" (text/plain)]

# -*- coding: latin1 -*-
# vim: set fileencoding=latin1
#
# PyTiCroque - Copyright Philippe Fremy 2009
#
# This file is released under the BSD License, see the accompanying file LICENSE.txt
#

import locale, sys
locale.setlocale( locale.LC_ALL, '' )

from PyQt4 import QtGui, QtCore

def dbg( s ):
    print (u'PTCrWindow: %s' % s).encode( locale.getlocale()[1] )

class PTCrWindow( QtGui.QTextEdit ):

    def __init__( self ):
        QtGui.QTextEdit.__init__( self )
        self.initAppIcon()
        self.initSystray()
        self.timer = QtCore.QTimer()
        self.timer.start( 2  * 1000 ) 
        QtCore.QObject.connect( self.timer, QtCore.SIGNAL('timeout()'), self.addMsg )
        self.appendEvent( 'QPyTiCroque is alive !' )

    def initAppIcon( self ):
        pixmap = QtGui.QPixmap( 'croquemonster.png' )
        dbg( 'pixmap size: %dx%d' % (pixmap.width(), pixmap.height()) )
        self.appIcon = QtGui.QIcon( pixmap )
        self.setWindowIcon( self.appIcon )

    def initSystray( self ):
        self.systray = QtGui.QSystemTrayIcon( self.appIcon , self )
        self.systray.setToolTip( 'PyTiCroque' )
        self.systray.show()

        dbg( 'SystemTray available: %s' % str( bool ( QtGui.QSystemTrayIcon.isSystemTrayAvailable() ) ) )
        dbg( 'SystemTray supports messages: %s' % str( bool ( self.systray.supportsMessages() ) ) )

    def addMsg( self ):
        self.appendEvent( 'timer event!' )

    def appendEvent( self, s ):
        dbg( s )
        self.append( s )
        self.systray.showMessage( QtCore.QString(u'Evenement PyTiCroque'), QtCore.QString(s),
                QtGui.QSystemTrayIcon.Information, 100 * 1000 )

DEBUG_FLAG=False
        
def main():
    app = QtGui.QApplication([])
    w = PTCrWindow()
    w.show()
    app.exec_()
    w.systray.hide()
    app.processEvents()

if __name__ == '__main__':
    main()



_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic