Re: How to call WebKit.DOMDocument.evaluate function in python



Ah, that's good news. Happens to me sometimes as well when trying to
translate C docs to Python :) Sometimes Python's help can be your friend
"help(WebKit.DOMDocument.evaluate)"



On Tue, Jul 2, 2013 at 5:12 PM, Niranjan Rao <nhrdls gmail com> wrote:

 Simon,

Thanks for the pointer. I noticed that I made a stupid mistake  and was
sending document as a first parameter.

Your example opened my eyes and now it looks like its running ok.

Thanks,

Niranjan


On 07/02/2013 02:37 PM, Simon Feltman wrote:


 On Tue, Jul 2, 2013 at 10:35 AM, Niranjan Rao <nhrdls gmail com> wrote:

And yes, I had tried creating empty WebKit.DOMXPathResult object and
passing it. Did not work.


 It would be helpful to know the details of what didn't work. Code
examples of what you have tried, or steps to reproduce the problems you are
seeing can be invaluable for getting help. A simple example on my system
shows using an empty DOMXPathResult is actually working:

 In [1]: from gi.repository import WebKit
 In [2]: view = WebKit.WebView()
In [3]: dom = view.get_dom_document()
 In [4]: dom.evaluate('/', dom, WebKit.DOMXPathNSResolver(), 0,
WebKit.DOMXPathResult())
 Out[4]: <DOMXPathResult object at 0x7fc670b08eb0 (WebKitDOMXPathResult
at 0x2ea90f0)>

  This is with PyGObject/GTK+ version 3.8.2 (not sure about WebKit
version). If this does not work with older versions, supporting a fallback
with ctypes hacks sounds reasonable. This would allow support for older
versions while ensuring use of proper API on newer versions. If the
__gpointer__ attribute is not available or not useful, you can still find
the pointer to the GObject by using offsets of the pointer field on the
PyGObject wrapper. But code examples of what you have already tried will be
needed to further aid you with this.

 -Simon






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]