google-code-export / pywebkitgtk

Automatically exported from code.google.com/p/pywebkitgtk
Other
1 stars 0 forks source link

add javascript execution / evaluation capabilities #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
        about = "<html><body id='body'></body></html>"
        self._browser.load_string(about, "text/html", "iso-8859-15", "about:")

        self.show_all()

    def js_test(self):

        main_frame = self._browser.get_main_frame()
        print dir(main_frame)
        ctx = main_frame.gjs_get_global_context()
        print dir(ctx)
        doc = ctx.get_by_name("document")
        print doc, dir(doc)
        doc.fred = 5
        print doc.fred
        win = doc.get_by_name("window")
        print win, dir(win)
        print doc.get_by_name("fred")
        print doc.get_by_name("joe")
        #doc.eval("para = document.createTextNode('Some content.');")
        ctx.eval("console.error('hello');")

doc.execute("document.getElementById('body').appendChild(document.createTextNode
('Some
content.'));")
        #doc.execute("document.appendChild(document.createTextNode('Some
content.'));")
        #doc.execute("para2 = document.createTextNode('Some content.');")
        #para = doc.get_by_name("para")
        #print "para", para, para.get_string()
        #doc.execute("document.appendChild(para);")

    def _set_title(self, title):
        self.props.title = title

    def _loading_start_cb(self, view, frame):
        main_frame = self._browser.get_main_frame()
        if frame is main_frame:
            self._set_title(_("Loading %s - %s") %
(frame.get_title(),frame.get_uri()))
        self._toolbar.set_loading(True)

    def _loading_stop_cb(self, view, frame):
        # FIXME: another frame may still be loading?
        self._toolbar.set_loading(False)
        self.js_test()

Original issue reported on code.google.com by luke.lei...@gmail.com on 20 Aug 2008 at 2:28

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by jmalo...@gmail.com on 27 Oct 2008 at 11:58

GoogleCodeExporter commented 9 years ago
Hy there.
I've compiled the latest pywebkitgtk source( 1.0.2 ) only with this patch and I 
get
this error when I try to run the example:

Traceback (most recent call last):
  File "./program3.py", line 26, in <module>
    import webkit
ImportError: /usr/lib/python2.5/site-packages/gtk-2.0/webkit.so: undefined 
symbol:
gjs_value_get_nth_attribute

What do I do wrong ? I would really like to use pywebkitgtk for my project, and 
DOM
access it's all that I'm missing now.

Original comment by fr.dan...@gmail.com on 2 Nov 2008 at 11:37

GoogleCodeExporter commented 9 years ago
it is essential that you use the webkit-glib version.
see http://pyjd.org and follow the links, there.

if you have a 64-bit x86 system (intel or amd) then there's a pre-built version 
of
debian packages, on the http://pyjd.org site - if you're not using debian, the 
.debs
can easily be unpacked or converted (e.g. with "alien").

also, can i recommend that you send a message to the webkit-dev mailing list, to
encourage people to get their act together?

contact me on pyjamas-dev google group to discuss this further if you need more
assistance.

Original comment by luke.lei...@gmail.com on 2 Nov 2008 at 1:15

GoogleCodeExporter commented 9 years ago
I added initial support for this in SVN. It's still a work-in-progress so it's 
not
working yet. To build, just pass --with-gjs when invoking autogen.sh.

Original comment by jmalo...@gmail.com on 18 Nov 2008 at 1:55

GoogleCodeExporter commented 9 years ago
The bindings will only support WebKitGtk as it is upstream. If you need a 
feature in
WebKitGtk, I encourage you to file a bug at http://bugs.webkit.org.

Thanks for the bug report.

Original comment by jmalo...@gmail.com on 28 May 2009 at 9:55