[webkit-gtk] Bug#749251: cyclograph-gtk2: depends on python-webkit which is deprecated

Emilio Pozuelo Monfort pochu27 at gmail.com
Thu Jun 26 12:16:24 PDT 2014


Hi,

Sorry for the late reply.

On 17/06/14 21:35, Federico Brega wrote:
> 2014-06-09 20:40 GMT+02:00 Emilio Pozuelo Monfort <pochu at debian.org>:
>>> >> For the second issue there is no documentation for python which makes
>>> >> the transition to webkit2 a little slow.
>>> >> Do you have any example about how to execute javascript and get
>>> >> results back in python?
>> >
>> > There is webkit_web_view_run_javascript() and
>> > webkit_web_view_run_javascript_finish(), see
>> >
>> > http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#webkit-web-view-run-javascript
>> >
>> > Is that what you need?
> Hello Emilio,
> 
> thank you for your help. I had already seen the page you linked, but
> it is C code. It should be straightforward to translate int python but
> it doesn't work, that's why I asked for a python example.
> We tried to make it work with webkit2 but result_js.get_value() throws
> a type error:
> TypeError: Couldn't find conversion for foreign struct 'JavaScriptCore.Value'
> I attached a minimal example to better explain how we're using the library.
> Do you have any suggestion? Is it the case to report a bug of
> gir1.2-webkit2-3.0?

I don't know about that. Perhaps somebody from the upstream ml can shed some
light. Cc'ing it.

[ for webkit-gtk@: Federico is porting his app from python-webkit (the old
static libwebkitgtk-1.0 python bindings) to gir1.2-webkit2-3.0, see the code
below. ]

Regards,
Emilio

> Regards
> 
> --
> Federico
> 
> 
> example.py
> 
> 
> from gi.repository import Gtk, WebKit2
> 
> def get_res(view, result):
>     result_js = view.run_javascript_finish(result)
>     if result_js is None:
>         return
>     v = result_js.get_value()
>     print(v)
> 
> view = WebKit2.WebView()
> 
> sw = Gtk.ScrolledWindow() 
> sw.add(view) 
> 
> win = Gtk.Window()
> win.connect("delete-event", Gtk.main_quit) 
> win.add(sw)
> win.set_default_size(400, 200)
> win.show_all() 
> 
> view.load_uri("http://w3.org/")
> 
> view.run_javascript("document.URL", None, get_res)
> 
> Gtk.main()



More information about the webkit-gtk mailing list