Взаимодействие pywebkitgtk и javascript
Сабж можно осуществить c помощью дополнительной библиотеки: pyjavascriptcore
Есть сборки для убунты в ppa
Пакеты будут в следующих версиях ubuntu и debian
Пользоваться примерно так:
Есть сборки для убунты в ppa
Пакеты будут в следующих версиях ubuntu и debian
Пользоваться примерно так:
$ import javascriptcore
$ cx=javascriptcore.JSContext(frame.get_global_context())
cx.globalObject.document.write('test')
$ func=cx.evaluateScript('window.foo=function(a){return a*2;}')
$ cx.globalObject.window.foo
Out: <javascriptcore.JSBoundMethod object at 0x94e84dc>
$ func(6)
Out: 12.0
class MyWebView(webkit.WebView):
def get_selection(self, callback, *args):
self.eval('return document.getSelection()', callback, *args)
def _got_response_cb(self, view, msg, n, something, callback, *args):
self.disconnect(self._got_response)
callback(msg.strip(), *args)
view.stop_emission('console-message')
def eval(self, js, callback, *args):
self._got_response = self.connect("console-message", self._got_response_cb, callback, *args)
self.execute_script('console.log((function(){%s\n})());' % js)
Потом наткнулся на более простой способ в интернетах:
class MyWebView(webkit.WebView):
def get_selection(self):
self.execute_script('oldtitle=document.title;document.title=document.getSelection();')
sel = self.get_main_frame().get_title().strip()
self.execute_script('document.title=oldtitle;oldtitle=null;')
if sel == self.title:
return
return sel






Comments
In my opinion you should develop this topic greatly!
How did you get to be this good? Its amazing to see someone put so much passion into a subject. Im glad I came across this. Im glad I took the time to read on past the first paragraph. Youve got so much to say, so much to offer. I hope people realise this and look into your page.
freelance writer
In fact, that is not hard to buy custom essay when people do not have time to do a research. Thence, it’s normal to find custom writing corporation.
Very grateful to this website, I downloaded a lot of and learned a lot, I hope you will continue to work hard, I would often visit here.
Awesome way of thinking,good things, Presently there are many people looking about the same topic.,now they will find the required options by your content.We are now looking forward for extra info about it
I found very useful and interesting posts in this blog which is the great signs for a good blogger.