[PyKDE] Using the Kate KPart from Python

Jim Bublitz jbublitz at nwinternet.com
Wed Dec 6 21:33:13 GMT 2006

On Wednesday 06 December 2006 10:07, Paul Giannaros wrote:
> Hi,
> How would you go about using a KatePart but getting some more fine-grained
> control? I've got an editor widget up displaying in my KParts::MainWindow
> (loading via createReadOnlyPart('libkatepart' .....)), but I don't see how
> I use the part for functionality past the basic KPart functions (i.e
> part.openURL). The examples on the kate-editor website
> (http://kate-editor.org/article/embedding_katepart_in_your_application)
> require you to import kate header files to cast to a KTextEditor::Document
> and then a Kate::View. I can't see how i'd do something equivalent in
> PyKDE, as I see no mention of the KTextEditor interface in the docs.
> Is this at all possible?

Yes, it's possible. You should be able to use DCOP to communicate with the 
part, to the extent that meets your needs.

Otherwise, there are a couple of other approaches, depending on how Kate is 
structured. One is to write sip bindings for the Kate part and supporting 
lib(s), the same as PyKDE does. That's likely to be way more than most people 
want (binding a complete application and supporting libs).

Another way is to write lightweight wrappers in C++ that expose only the 
objects you want to manipulate. That's usually not too difficult.

A third way (works for things like kspread and maybe other koffice apps) is to 
rewrite the application's front end to make it a Python application - the 
koffice apps, for example, are all kparts with a front end that loads them 
(in theory - in practice the division isn't quite that clean). That would 
involve wrapping a few top level objects. I don't mean rewriting the entire 
app in Python, just wrapping the higher level functions,   for example, load 
file, create new window, find & replace - the kind of stuff that's usually in 
the menus.

I've looked at doing bindings for KTextEditor (I believe it's in kdelibs?), 
but for some reason have always decided not too. There is some stuff in kdeui 
(find an replace, KEdit, etc) that allows you to do a simple editor pretty 


More information about the PyQt mailing list