This forum has been archived. All content is frozen. Please use KDE Discuss instead.

KNotify basics

Tags: None
(comma "," separated)
EduardoMartins
Registered Member
Posts
3
Karma
0
OS

KNotify basics

Fri Nov 19, 2010 10:09 pm
Hello,

I am writing a simple program to display my study notes every few minutes. I would like to use KNotify (like this) instead of the QSystemTrayIcon balloon. How can I call KNotify instead of the balloon?


Code: Select all
from PyQt4.Qt import QApplication, QSystemTrayIcon

app = QApplication([])
tray = QSystemTrayIcon(ic)
tray.setVisible(True)

mynote = """Economics is the social science that analyzes the production, distribution, and consumption of goods and services."""

tray.showMessage("Memorize!", mynote, tray.Critical, 20000)


Thanks,

Eduardo
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: KNotify basics

Sat Nov 20, 2010 4:19 am


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
EduardoMartins
Registered Member
Posts
3
Karma
0
OS

Re: KNotify basics

Sat Nov 20, 2010 5:34 pm
Thanks for your time, bcooksley.

I updated kdelibs with «sudo apt-get install kdelibs» and tried:

Code: Select all
from PyQt4.Qt import QApplication, QSystemTrayIcon, QIcon
>>> import dbus
>>> notify = dbus.Interface(dbus.SessionBus().get_object('org.kde.VisualNotifications', '/VisualNotifications'), 'org.kde.VisualNotifications')


But got the following error message:

Code: Select all
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    notify = dbus.Interface(dbus.SessionBus().get_object('org.kde.VisualNotifications', '/VisualNotifications'), 'org.kde.VisualNotifications')
  File "/usr/lib/pymodules/python2.6/dbus/bus.py", line 244, in get_object
    follow_name_owner_changes=follow_name_owner_changes)
  File "/usr/lib/pymodules/python2.6/dbus/proxies.py", line 241, in __init__
    self._named_service = conn.activate_name_owner(bus_name)
  File "/usr/lib/pymodules/python2.6/dbus/bus.py", line 183, in activate_name_owner
    self.start_service_by_name(bus_name)
  File "/usr/lib/pymodules/python2.6/dbus/bus.py", line 281, in start_service_by_name
    'su', (bus_name, flags)))
  File "/usr/lib/pymodules/python2.6/dbus/connection.py", line 620, in call_blocking
    message, timeout)
DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.kde.VisualNotifications was not provided by any .service files


What am I doing wrong?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: KNotify basics

Sun Nov 21, 2010 7:50 am
"knotify4" is likely not running, although if you are in a KDE session, it should be.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
EduardoMartins
Registered Member
Posts
3
Karma
0
OS

Re: KNotify basics

Sun Nov 21, 2010 2:54 pm
Thank you again, bcooksley. I understand the problem now! It happens that I found the notifier so pretty, I thought it couldn't be Gnome, it had to be KDE...! Ubuntu uses NotifyOSD.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: KNotify basics

Mon Nov 22, 2010 4:12 am
Both GNOME and KDE implement a XDG Notifications specification, I suggest implementing that. Look at org.freedesktop.Notifications on D-Bus.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]