[PyKDE] RE: PyKDE digest, Vol 1 #584 - 13 msgs
Jim Bublitz
jbublitz at nwinternet.com
Sun Feb 10 14:23:26 GMT 2002
On 09-Feb-02 Henrik Motakef <henrik.motakef at web.de> wrote:
> Two questions about PyKDE2:
> (How) Can I connect KStdActions to a Python method? It looks as
> if I only can use form
> KStdAction.foo(self, SLOT("bar()"),self.actionCollection()),
> which respects overridden methods, but doesn't work with methods
> not contained in KMainWindow.
I don't have an answer to your question, and in fact you probably
already know all the stuff that follows, but others on the list may
not. I'll try and play around with this a little, but won't be able
to get to it immediately.
First, if you haven't already done so, go to:
http://developer.kde.org/documentation/library/index.html
and bookmark it or download something like:
"KDE 2.2 Online Library Reference"
KStdAction is detailed in the kdeui section. You'll also want to
look at KAction, since KStdAction is just a wrapper for creating
KAction objects. Both have fairly detailed examples of C++ usage -
the Python usage is similar (but probably not identical :( ).
As far as the method being invoked having to be included in
KMainWindow, I'm not sure that's correct, although I haven't tried
that either. If it is, you can always call a method in another
object indirectly via a KMainWindow method. I'll take a look at
this too.
The applications I've built so far all have a main window inherited
from KMainWindow and I've included all of the UI actions in that
class and made that the top level class that invokes all of the
other behavior for the app.
A good place to start is the 'pykless.py' example which is in the
'example' directory in the PyKDE2 distribution. This only uses
KStdAccel at the moment, but should be able to use KStdAction (for
example for the 'File | Open' action, which is probably what I'll
try first). The original 'kless' code that I stole 'pykless' from is
in the kdesdk source in the 'kexample' directory, if you want to
try it in C++ first.
> Is it possible to write, say, a Konqueror Plugin in Python? It
> looks like all neccessary classes are implemented, however I
> obviously cannot build a lib<mypart>.so. (Probably related - is
> it possible to implement KIOSlaves?)
Again, I don't have the answer and I'm not familiar with the
plug-in architecture for Konqueror, or the inter-process
communications stuff as done in KDE - I've just done the bindings
rather mechanically. If a plugin requires direct calls to other C++
libs, then there would need to be some additional Python bindings
done to accomplish that. I've done a little bit of work with one of
the guys from a KDE project on something similar, but that case
involved generating an additional set of bindings for him. I can do
this pretty easily if you have a simple small lib you want bindings
for. sip does this nicely, but the docs are pretty minimal.
In general I would like it to be extremely easy to use PyKDE2 either
to write plugins for things like Konqueror or noatun, and to be
able to use Python/PyKDE2 for scripting KOffice, KDevelop, etc.
I expect that this will require some hooks in the KDE apps or some
standard mechanism and will require some extensions to PyKDE2 and
maybe sip as well. I (or somebody) will probably do some work on
this once PyKDE2 is caught up to KDE3.0 (the KDE developers aren't
interested in going back into 2.x, and I can't blame them for that).
To say I don't know a lot about this at the moment is an
understatement.
There are a couple of problems with this: first, I don't think the
KDE guys want to require that Python libs be linked into KDE apps,
and second, PyKDE2 is *very* large (look at the size of the libs it
installs in 'site-packages'). The first problem is solvable, but
I'm not sure what can be done about PyKDE2's size.
As a last wild guess, you might want to take a look at the standard
Python 'dl' module (Sect. 8.5 in the Library Reference) - KDE also
has some similar functionality for dll's. I don't know if this gets
anywhere, but it might be worth a look.
Any contributions (example code, tutorial, a post to the list) from
anyone who knows something about this stuff would be tremendously
helpful.
Jim
More information about the PyQt
mailing list