QWebView: notify python when I clicked on a certain web eleemnt

Gelonida gelonida at gmail.com
Thu Feb 24 00:02:15 CET 2011


Hi Damjan,

Thanks for your answer

On 02/21/2011 05:09 PM, Дамјан Георгиевски wrote:
>> I have a web page (existing page, can't modify it) and I would like
>> to browse it in a QtWebview. (This is already working

>> When I click on a certain element e.g. "<span id="clickme"></a>"
>> I would like to notify my python script.
>>
>> What is important:
>> I don't want to change anything else in the web pages behaviour (This
>> means if clicking on this element will call some java script
>> functions, load a pag, then this should still happen.
> 
> 
> You can inject JavaScript using the method 
> QWebElement::evaluateJavaScript()
> 
> Also you can insert a Python object in the JS runtime with 
> QWebFrame::addToJavaScriptWindowObject()
> see here:
> http://pysnippet.blogspot.com/2010/01/calling-python-from-javascript-in-
> pyqts.html
> 

> 
> so make a Python object with some methods you'd wish to call, then 
> evaluate some small JS that will bind the click event on your element to 
> the method of the Python object.
> 

OK, but how do I make sure, that I don't override an existing binding to
the element's click() event?



I  will start playing with it.




>




More information about the Python-list mailing list