To make this very simple example working, I've had to modify the pyrunner.py file that I checked out in the last post. I don't know if this changes will be necessary in newer KDE versions (mine is 4.3.4), but by now this patch can be used.
And here is a final working example:
And here is a final working example:
from PyKDE4 import plasmascript
from PyKDE4.plasma import Plasma
class EchoRunner(plasmascript.Runner):
def match(self, search):
if not search.isValid():
return
term = search.query()
if term.length < 2:
return
m = Plasma.QueryMatch(self.runner)
m.setType(Plasma.QueryMatch.ExactMatch)
m.setText('You said "%s"' % term)
m.setData(term)
search.addMatch(term, m)
def run(self, search, action):
print 'You said "%s"' % action.data().toPyObject()
def CreateRunner(parent):
return EchoRunner(parent)
I think it is self explainable, but you can leave any question in the comments.
You can also download the full example structure ready to install from here.
Comments
Post a Comment