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

Plasma development using pyhton

Tags: None
(comma "," separated)
mobilehunter
Registered Member
Posts
17
Karma
0
OS

Plasma development using pyhton

Tue Apr 07, 2009 3:47 am
Last week i just learned python and kde programming, by creating plasmoid.
I have followed the tutorial from kde site.
Now i'm stuck with KNotification, i just want to display a button at my plasmoid then if i press the button, i want to see a notification like what kopete do when user online.

From the documentation i should create notifyrc file. And copied to /usr/kde/4.2/share/apps/appletname/

Since i donot know how to copy the notifyrc automatically at install time, i copied manually. But the notification still not displayed.
So my questions are:
1. How to install notifyrc automatically for Python Plasmoid?
2. Why the notification failed?

Thanks.

Code: Select all
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtXml import *
from PyKDE4.plasma import Plasma
from PyKDE4 import plasmascript
from PyKDE4.kdeui import *
 
class NotificationPlasmaApplet(plasmascript.Applet):
    def __init__(self,parent,args=None):
        plasmascript.Applet.__init__(self,parent)

    def init(self):
        self.setHasConfigurationInterface(False)
   self.setAspectRatioMode(Plasma.Square)
   
   self.theme = Plasma.Svg(self)
   self.theme.setImagePath("widgets/background")
   self.setBackgroundHints(Plasma.Applet.DefaultBackground)
   self.layout = QGraphicsLinearLayout(Qt.Vertical,self.applet)
   self.labelFirstHeader = Plasma.Label(self.applet)
   self.button = Plasma.PushButton(self.applet)
   self.button.setText("hello")
   self.connect(self.button, SIGNAL("clicked()"), self.notify)
   self.layout.addItem(self.button)

    def notify(self):
        print "notify"
        KNotification.event("Updates", "hello", KIcon("konqueror").pixmap(QSize(22,22)))

def CreateApplet(parent):
    return NotificationPlasmaApplet(parent)


And my notifyrc
Code: Select all
[Global]
Name=Notification Plasma
IconName=chronometer
Comment=Sample notification

[Event/Updates]
Name=Update event
Comment=Got update event
Action=Popup
mobilehunter
Registered Member
Posts
17
Karma
0
OS

RE: Plasma development using pyhton

Tue Apr 07, 2009 10:59 am
I have solved the no.2 problem.
I can see notification now.

First add this line
Code: Select all
from PyKDE4.kdecore import *


Second change old KNotification.event line, into this:
Code: Select all
KNotification.event("Updates", "hello", KIcon("konqueror").pixmap(QSize(22,22)),None,KNotification.CloseOnTimeout,KComponentData("notplasma","notplasma",KComponentData.SkipMainComponentRegistration))
mobilehunter
Registered Member
Posts
17
Karma
0
OS

RE: Plasma development using pyhton

Wed Apr 08, 2009 6:15 am
Not really answered to my 1st question.
But i think i donot need to put my notifirc file globally.
I just need to put inside my local .kde/share/apps/appletname directory


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rblackwell