[PyKDE] Is PyKDE good for my project?
jbublitz at nwinternet.com
Mon Jun 21 23:16:00 BST 2004
On Monday 21 June 2004 22:07, Maurizio Colucci wrote:
> I am evaluating PyKDE for my project.
> Can I write a kicker applet completely in PyKDE? If so, could you please
> give me some hint how to do it? (e.g., where do I put the init() function,
> where do I copy the .py file, how do I cope with the requirement of having
> a .la file...).
> If I can't, what is the least amount of C++ code I have to write?
The status of panel applet support is a little murky at the moment. It was
included in PyKDE-3.8, but removed from PyKDE-3.11 (and you don't want to go
back to 3.8). It will eventually be part of an addon package separate from
PyKDE (but requiring PyKDE), but the people (including me) doing the
development haven't worked out the details yet.
I have working code (including installation) and could probably send you
something if you're in a real hurry (let me know). Otherwise, a general
release is probably a month or more away (probably "more"). It requires sip
4.0, which is available in rc form now and final release soon.
Basically, the panel applet/extension (about the same for both) interface uses
a single C++ lib to handle all instances of Python-based applets or
extensions - you just need to install this, along with libpythonize.so, which
is a very simple wrapper for the Python interpreter. You don't need to write
There is an appletInstall.py application (needs some cleanup, but working)
which will simplify installing Python-based panel applets. Assume you write
someApplet.py: In someApplet.py, you need a factory function ("createApplet"
- the code is pretty much the same for all cases) and a class sub-classed
from KPanelApplet that actually implements your applet. What the installer
1. Creates a .desktop file that references "libsomeApplet.so" and places it
in the share/apps/kicker/applets directory along with your Python file.
2. Creates a symlink in the appropriate directory from libsomeApplet.so to
libpykpanelapplet.so (the single applet interface lib)
3. Creates a fake libsomeApplet.la file in the approprieate directory
(The installer does some file renaming too - your file will be installed as
someApplet_py_applet.py - not usually a big deal).
When kicker reads the .desktop file, it loads libpykpanelapplet (via the
symlinked name and fake .la file). libpykpanelapplet has the required 'init'
function which loads the Python interpreter supplied in the libpythonize.so
lib (if not already loaded), loads the requested Python applet script into
the interpreter, runs the factory function and returns a KPanelApplet * for
your applet back to kicker. sip handles all of the Python<=>C++ conversions
(in the createApplet function, which you can mostly just cut and paste).
Because of the way Python<=>C++ conversions are now handled, applets may be a
little more difficult to debug - I still have to look into that.
> Can I use KHTML with pyKDE? My app needs integrated web browsing.
There is a KHTML part example (pyKHTMLPart.py) in the examples/ directory of
PyKDE. All it does is load and display www.kde.org (it needs an active 'net
connection running of course). From there you can use the appropriate signals
and slots and additional KDE classes in PyKDE to create as much of a web
browser as you need.
I haven't looked at using KHTML as a plain widget lately, but the KParts
interface is probably a better way to go and you end up with a widget anyway.
More information about the PyQt