Re: [PyQt] PyKDE: problems sending singals to KPART

2008-06-07 Thread Marcos Dione
On Wed, Jun 04, 2008 at 02:36:37PM +0200, Thomas Winkler wrote:
   self.part.openURL(KURL('file:///home/tom/test.pdf'))
   self.connect(self, PYSIGNAL(sigNextSlide), self.part, 
 SLOT(slotNextSlide()))
   self.emit(PYSIGNAL(sigNextSlide), ())

in the case of the KHTMLPart, the signals are not in the part
itself, but in a inner ojject, so you end up doing:

QObject.connect (part, SIGNAL (completed()), func)
if type(part)==KHTMLPart:
QObject.connect (part.browserExtension(),
SIGNAL (openURLRequest (const KURL , const 
KParts::URLArgs )),
self.linkClicked)

see? maybe the kpdf one behaves similarly...

-- 
(Not so) Random fortune:
Getting in trouble is interesting. Getting out is educational.
-- Roberto Alsina
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] PyKDE: problems sending singals to KPART

2008-06-05 Thread Jim Bublitz
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

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] PyKDE: problems sending singals to KPART

2008-06-04 Thread Thomas Winkler
Dear List,

I'm working on integrating hte KPDF KPart int my PyKDE application. What I 
would like to do is to emit a signal to the slotNextPage() slot of the kpdf 
part (see: 
http://websvn.kde.org/branches/KDE/3.5/kdegraphics/kpdf/part.h?view=markup ).

A stripped down version of my code loos like this:


##

from qt import *
from kdecore import KCmdLineArgs, KURL, KApplication, KLibLoader, KShortcut
from kdeui import KMainWindow, KMessageBox, KAction, KStdAction, KKeyDialog
from kparts import KParts, createReadOnlyPart, createReadWritePart
import sys, os

FALSE = 0
TRUE  = not FALSE

class pyPartsMW (KParts.MainWindow):
def __init__ (self, *args):
apply (KParts.MainWindow.__init__, (self,) + args)
self.setGeometry (0, 0, 600, 500)
self.part = createReadOnlyPart(libkpdfpart, 
self, test, KParts::ReadOnlyPart)
self.setCentralWidget(self.part.widget())

# TODO: point to valid PDF file
self.part.openURL(KURL('file:///home/tom/test.pdf'))
self.connect(self, PYSIGNAL(sigNextSlide), self.part, 
SLOT(slotNextSlide()))
self.emit(PYSIGNAL(sigNextSlide), ())



def main():
app = KApplication(sys.argv, TestApp)
win = pyPartsMW (None, partBeamer)
win.show()
app.exec_loop()


if __name__ == '__main__':
main()

##


So embedding the kpdf kpart works and I can load a pdf file.
But the code fails on the self.emit statement with the following message:

[...]
  File min.py, line 20, in __init__
self.emit(PYSIGNAL(sigNextSlide), ())
NameError: Invalid slot slotNextSlide

I'm note sure what I'm doing wrong here. I tried with and without () after 
slotNextPage but without success. From the part.h file referenced above one 
can see that the slotNextPage method is protected. Might this be the problem?
On the other hand, the openURL() method is also declared protected and I have 
no problems calling that one.

One more note: I managed to call the slotNextSlide() method using KDCOP. Would 
using dcop from withtin pykde be an option?

I'd be happy if someone could help me with this one. What I basically want to 
do is to embed kpdf-part in a pykde application and all methods (slots) 
provided by kpdf-part (especailyl controlling slides, switching to 
presentation mode etc). I'd prefer using direct method calls or signals. A 
DCOP based solution would also be OK.

Thank you very much,
-- 
Thomas Winkler
[EMAIL PROTECTED]
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] PyKDE: problems sending singals to KPART

2008-06-04 Thread Thomas Winkler
Hello,

 self.connect(self, PYSIGNAL(sigNextSlide), self.part,
  SLOT(slotNextSlide()))
 self.emit(PYSIGNAL(sigNextSlide), ())

 wild guess here, but did you try:
 self.connect(self, PYSIGNAL(sigNextSlide), self.part.slotNextSlide)

 or you could be missing a piece of the signal signature (maybe
 KPart::slotNextSlide()  ?)


Thank you for your suggestions. Unfortunately both do not work for me.

An additional note: I had a mistake in the source I posted. The slot I want to 
call is named slotNextPage and not slotNextSlide. But the problem still 
remains.

Thank you,

-- 
Thomas Winkler
[EMAIL PROTECTED]
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt