How to emit signal to a PyQtWebkitView javascript from the Application?

This is a very good question, I got stuck on it some time! I will show you an example of two way communication: from python to javascript and vice-versa, hope it helps:

import PyQt4.QtGui as gui, PyQt4.QtWebKit as web, PyQt4.QtCore as core

class MyMainWindow(gui.QMainWindow):    

    proccessFinished = core.pyqtSignal()

    def __init__(self, parent=None):
        super(MyMainWindow,self).__init__()

        self.wv = web.QWebView()
        self.setCentralWidget(self.wv)

        #pass this main window to javascrip
        self.wv.page().mainFrame().addToJavaScriptWindowObject("mw", self)          

        self.wv.setHtml("""
        <html>
        <head>
            <script language="JavaScript">
                function p() {
                    document.write('Process Finished') 
                }
                mw.proccessFinished.connect(p)                
            </script> 
        </head>
        <body>
            <h1>It works</h1>
            <input type=button value=click onClick=mw.doIt()></input>
        </body>
        </html>
        """)

    @core.pyqtSlot()
    def doIt(self):
        print('running a long process...')
        print('of course it should be on a thread...')
        print('and the signal should be emmited from there...')
        self.proccessFinished.emit()


app = gui.QApplication([])

mw = MyMainWindow()
mw.show()

app.exec_()