[Kde-bindings] Python plasmoid

Jeremy Sanders jeremy at jeremysanders.net
Mon Dec 15 23:03:43 UTC 2008


Hi - I'm having problems with a minimal python plasmoid I'm trying to 
write. This is with kde 4.1.3 on Ubuntu Intrepid. There seems to be a 
python-plasma and python-plasma-examples installed. I don't know how 
different these are to the kde 4.2 versions.

The plasma-pyclock example seems to work, except the configuration dialog 
box never seems to come up.

I've created a minimal example. In a zip file pytest.zip I have the 
following files:

metadata.desktop:
[Desktop Entry]
Encoding=UTF-8
Name=Python Test
Type=Service
ServiceTypes=Plasma/Applet
X-Plasma-API=python
Icon=chronometer

X-KDE-PluginInfo-Author=Jeremy Sanders
X-KDE-PluginInfo-Email=jeremy at jeremysanders.net
X-KDE-PluginInfo-Name=pytest
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true

In contents/code/main.py:

#!/usr/bin/python

import PyQt4.Qt as qt
import plasma
from PyKDE4.plasma import Plasma
from PyKDE4.kdecore import KGlobal

class PyTestApplet(plasma.Applet):
     def __init__(self, parent, args=None):
         plasma.Applet.__init__(self,parent)

     def init(self):
         self.setHasConfigurationInterface(False)
         self.resize(125, 125)
         self.setAspectRatioMode(Plasma.Square)

     def shape(self):
         path = QPainterPath()
         path.addEllipse(self.boundingRect().adjusted(-2, -2, 2, 2))
         return path

     def paintInterface(self, painter, option, rect):
         painter.drawText(rect, "Hi there")

def CreateApplet(parent):
     return PyTestApplet(parent)


I've tried adding this zip file with plasmapkg --install into my home 
.kde directory. (plasmapkg --remove never seems to be able to delete it 
however)

It installs apparently okay, but the applet doesn't initialize. I get 
this in the .xsession logs:

...
find_module(pytest,None)
find_module(pytest,None)
find_module(pytest,None)
Traceback (most recent call last):
   File 
"/usr/share/kde4/apps/plasma_scriptengine_python/pyappletscript.py", line 
51,
in init
     self.module = __import__(plugin_name+'.main')
ImportError: No module named pytest.main
TypeError: invalid result type from PythonAppletScript.shape()
TypeError: invalid result type from PythonAppletScript.shape()
TypeError: invalid result type from PythonAppletScript.shape()

It's not clear to me what the import magic is doing. It doesn't seem to be 
able to import the main.py file.

Can anyone suggest anything? Is my python-plasma package just too old?

Thanks

Jeremy

-- 
Jeremy Sanders <jeremy at jeremysanders.net>
http://www.jeremysanders.net/                Cambridge, UK
Public Key Server PGP Key ID: E1AAE053



More information about the Kde-bindings mailing list