pythonpyqtkde-plasmapykde

KStatusNotifierItem not working in newer versions of KDE 4


I have an applet that uses KStatusNotifierItem of PyKDE4. In Arch Linux with versions as such (Qt - 4.8.4, KDE Development Platform - 4.9.5) taken from kde4-config -v, it works.

However, in Kubuntu 12.10 with versions (Qt - 4.8.3, KDE Development Platform - 4.9.98), it's not working. Could anyone point me to how i can debug it?

Here's an example of the code.

#!/usr/bin/python2
# -*- coding: utf-8 -*-

import sys
from PyQt4 import Qt
from PyQt4.QtCore import QObject, QString
from PyKDE4.kdeui import KStatusNotifierItem


App = Qt.QApplication(sys.argv)

class Notifier(QObject):
  def __init__(self, parent=None):
    QObject.__init__(self, parent)

    self.tray = KStatusNotifierItem(self)
    self.tray.setCategory(KStatusNotifierItem.Communications)
    self.tray.setIconByName(QString("/usr/share/icons/oxygen/16x16/categories/applications-internet.png"))
    self.tray.setStatus(KStatusNotifierItem.Active)
    self.tray.setToolTipIconByName(QString("/usr/share/icons/oxygen/16x16/categories/applications-internet.png"))

if __name__ == '__main__':
  notifer = Notifier()
  App.exec_()

Thanks.


Solution

  • I have also reported this in bugs.kde.org, and they have found a solution. Basically the line self.tray = KStatusNotifierItem(self) needs to be changed to self.tray = KStatusNotifierItem("someID", self).