[PyKDE] KSystemTray issues

mbouchar mbouchar at bioinfo.ulaval.ca
Tue Jun 21 13:04:29 BST 2005


Your application doesn't seems to have a name.
I had the same problem when using KStdAction to generate the help menu.

To give a name to your application, you must use KAboutData

This is a modified example of an application I'm developping :

from xxx import version

def getAboutData():
    # Adding informations about the program
    aboutData = KAboutData(version.__program__, version.__program__,
                           version.__version__, version.__description__,
                           KAboutData.License_GPL_V2, version.__copyright__)
    for author in version.__authors__:
        aboutData.addAuthor(author["name"], "", author["email"])
    aboutData.setBugAddress(version.__bugs__)
   
    return aboutData

if __name__ == "__main__":
    # Adding some parameters to the application
    sys.argv.extend(['--icon', 'source_py', '--caption',
                     version.__description__ + ' v' + version.__version__])
    aboutData = getAboutData()

    # Initialisation with KCmdLineArgs to use KAboutData
    KCmdLineArgs.init(sys.argv, aboutData)
    # Adding command line options
    KCmdLineArgs.addCmdLineOptions([("+file", "xxx file to open", "")])

    # KApplication with empty arguments, as the application
    # instance is already created
    kapp = KApplication()

Shahar Weiss wrote:

>Hello everyone.
>I have a little problem with a python script of mine, using the KSystemTray 
>widget.
>
>This is the code below (dirty I know), and here's a link to a screenshot: 
>http://members.lycos.co.uk/sweiss3/extra/menu.png
>
>The problem is the "unknown" caption which appears on top of the system tray 
>icon's menu. Can you please tell me what I'm doing wrong?
>
>Here's the code:
>
>from qt import *
>from kdecore import *
>from kdeui import *
>from updateform import *
>import sys
>if __name__ == "__main__":
>	def processUpdateFile(fileString, ListView):
>		updateFile = open(fileString, 'r')
>		packageList = updateFile.readlines()
>		updateFile.close()
>		for i in range(len(packageList)):
>			packageString=packageList[i].split(' ')
>			package = QListViewItem(ListView, packageString[0], packageString[1], 
>packageString[2])
>
>	app = KApplication(sys.argv, "Updater")
>	form = UpdateForm()
>	trayicon = KSystemTray(form, "System Updater")
>	trayicon.setPixmap( QPixmap("konsole.png") )
>	trayicon.setCaption("New updates are available")
>	trayicon.contextMenu().insertTitle("System Update")
>#	b=KPopupMenu()
>#	b.insertTitle("Testing")
>#	trayicon.contextMenuAboutToShow(b)
>	trayicon.show()
>	form.show()
>	processUpdateFile('/home/sweiss/testpac.txt',form.packageListView)
>	app.setMainWidget(form)
>	app.exec_loop()
>	trayicon.hide()
>
>
>Thanks in advance,
>Shahar.
>
>_______________________________________________
>PyKDE mailing list    PyKDE at mats.imk.fraunhofer.de
>http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
>  
>




More information about the PyQt mailing list