[PyQt] PyKDE: problems sending singals to KPART

Jim Bublitz jbublitz at nwinternet.com
Thu Jun 5 16:04:35 BST 2008


On Wednesday 04 June 2008 23:42, Thomas Winkler wrote:
> Hello,
>
> > Yes - short of writing some C++ DCOP would be the solution, if KPDF
> > exposes a sufficient interface via DCOP, which apparently it does.
>
> [...]
>
> > There is an example (example_dcopext.py) in PyKDE/examples.
>
> I had a look at the example. My feeling however is that it is not an option
> for me since, contrary to the example, I want to embed the kpart in my
> application instead a launching a separate process. For DCOP control as
> shown in the example I need the "$PROCNAME-$PID" id string which I
> obviously do not have.
> While writing the above the idea came to my mind that I could simply use
> the the name and pid of my own app which embeds the kpdf part and send dcop
> messages to my own app to control the kpdf part. So far so good.
> My app is planned to embed more than just one kpdf kpart but when
> inspecting my app with kdcop I only could see one single kpdf component
> (eben though my app has two of them). Using kdcop I can send messaes to the
> kpdf part. They are executed for the kpdf kpart that was last instantiated.
> I could not find a way to control the other kpdf kpart as it does not show
> up in kdcop. What is the reason for that?

You could fork each of the KPDF processes, and they'd have unique PIDs then. 
Another possibility is QXEmbed (should be an example for that in PyKDE too), 
however that can be somewhat unreliable in my experience with it.

You could also use KHTMLPart for the GUI and have that launch KPDF instances, 
although I don't know if that buys you any more control in your application.

> Coming back to the idea of writing some own c++ code: What exactly would I
> have to write?

You would need  a wrapper which 1) loads (or links to) the .so lib KPDF is 
based on (and since it's a KPart, it has a .so lib) and 2) makes the KPDF 
methods you want to use available in Python.

If you only want a method or two, you could look at the Python/C API to 
accomplish both of those. Most good books on Python usually include something 
about writing C modules to interface to Python. Otherwise, you can write a 
C++ wrapper that exposes the classes/methods you need and do bindings for it 
using sip.

Jim



More information about the PyQt mailing list