View Single Post
Old 06-20-2011, 10:41 AM   #24
burbleburble
Connoisseur
burbleburble began at the beginning.
 
Posts: 52
Karma: 38
Join Date: Jun 2011
Device: Kindle 3
@Kovid: Thanks for the references. They helped alot.

Some questions:
1) I'm still having trouble creating the bridge. In the following example code the bridge only works if the pyqtSignature is set to QVariant, or someother setup. It never works when set to QWebElement (and if I don't set anything, it apparently can't pass values)! But I very much need this functionality, and it shoud work as per the instructions on http://doc.qt.nokia.com/4.7-snapshot...it-bridge.html (under the section entitled 'QWebElement').

Here is an example of the code I am trying to use (it runs as a module, and the javascript should respond 'onclick'):

Code:
import sys
from PyQt4 import QtCore, QtGui, QtWebKit, Qt

class JSObject(QtCore.QObject):
    @Qt.pyqtSignature('QWebElement')
    def test(self, webelement):
        print('Comunication with jsobject worked!')
        #print(webelement.tagName()) #test if actually returned a webelement

def loadJSObject():
    webview.page().mainFrame().addToJavaScriptWindowObject("py_bridge", JSObject())
    webview.page().mainFrame().evaluateJavaScript('document.onclick = function test(event){window.py_bridge.test(event.target)}')

if __name__ == '__main__':
    app = QtGui.QApplication(sys.argv)
    webview = QtWebKit.QWebView()
    webview.page().connect(webview.page(), QtCore.SIGNAL('loadFinished(bool)'), loadJSObject)
    webview.setHtml('<html><body><p>This is a test html!</body></html>')
    webview.show()
    sys.exit(app.exec_())

2)Its very confusing for me to figure out how exactly to interface with the multiple files/classes dealing with epub/oeb. Is there a simple interface for the following two actions (a class and method to call, or something):
a)retrieve the html's from the epub. (a getHtml() type interface)
b)rewrite the epub, providing the html/toc/stylesheet information (a writeEpub(html, toc) type interface)


Thank you for your help!

Last edited by burbleburble; 06-20-2011 at 11:47 AM.
burbleburble is offline   Reply With Quote