pyjamas-desktop on MacOS - Need this to test pyjamas-desktop with the recent directory restructuring

77 views
Skip to first unread message

Sarvi Shanmugham

unread,
Oct 14, 2013, 1:17:51 AM10/14/13
to pyjs-...@googlegroups.com

Is there anyway for me run/test pyjamas-desktop on a MacOS?

Sarvi

Lex Berezhny

unread,
Oct 14, 2013, 1:30:58 AM10/14/13
to pyjs-...@googlegroups.com
I suspect the stuff Anthony has done with Webkit would allow you to run on Mac.

So, I think if it works on webkit in Linux it's safe to assume it will work with Mac. At last as far as pyjs is concerned because a lot of the work related to this is outside of the pyjs project.

Sarvi Shanmugham

unread,
Oct 14, 2013, 2:01:39 AM10/14/13
to pyjs-...@googlegroups.com
In which case I don't have anyway to test how my restructuring has impacted pyjamas-desktop.

Could I trouble you to quickly see if pyjamas-Desktop works with my directory restructuring at https://github.com/sarvi/pyjs

Sarvi

Sarvi Shanmugham

unread,
Oct 15, 2013, 3:42:33 AM10/15/13
to pyjs-...@googlegroups.com
Well, since no one seems to have the answer on how to get pyjamas-desktop on Mac I started trying to get it up myself.
I've been trying to see if I can replicate the Ubuntu process on my Mac and have been running into a few issues
trying to compile pythonwebkit from 

on my mac.
From what I can tell the dependencies have been met.
and autogen.sh succeeds when done as follows

PKG_CONFIG_PATH="/opt/local/lib/pkgconfig" LDFLAGS="-L/opt/local/lib" ../autogen.sh

Here is where I am running into a few errors which might require fixing in code.

../Source/JavaScriptCore/wtf/FastMalloc.h:265:1: error: '__private_extern__' does not name a type
................
../Source/JavaScriptCore/wtf/FastMalloc.h:272:1: error: '__private_extern__' does not name a type
make[1]: *** [Source/JavaScriptCore/API/libjavascriptcoregtk_1_0_la-JSBase.lo] Error 1


I tried something like the following to avoid having to change the code
I made a change in ../Source/JavaScriptCore/wtf/FastMalloc.h as follows

#if COMPILER(GCC) && OS(DARWIN)
// #define WTF_PRIVATE_INLINE __private_extern__ inline __attribute__((always_inline))
#define WTF_PRIVATE_INLINE __attribute__((visibility("hidden"))) inline __attribute__((always_inline))
#elif COMPILER(GCC)

which skipped past that error. Now I see the following error. I am not much of a C++ expert nor do I understand Webkit
I was hoping someone who got this stuff running on ubuntu might have a suggestion on how to fix this.

Can't even figure who owns pythonwebkit or where to ask this question.

./Source/JavaScriptCore/wtf/FastMalloc.h: In function 'void operator delete [](void*)':
../Source/JavaScriptCore/wtf/FastMalloc.h:272:25: warning: 'void operator delete [](void*)': visibility attribute ignored because it [-Wattributes]
../Source/JavaScriptCore/wtf/FastMalloc.h: In function 'void operator delete [](void*, const std::nothrow_t&)':
../Source/JavaScriptCore/wtf/FastMalloc.h:273:25: warning: 'void operator delete [](void*, const std::nothrow_t&)': visibility attribute ignored because it [-Wattributes]
../Source/JavaScriptCore/wtf/FastMalloc.cpp: In member function 'void WTF::TCMalloc_PageHeap::initializeScavenger()':
../Source/JavaScriptCore/wtf/FastMalloc.cpp:1523:56: error: expected primary-expression before '^' token
../Source/JavaScriptCore/wtf/FastMalloc.cpp:1523:57: error: expected primary-expression before '{' token
../Source/JavaScriptCore/wtf/FastMalloc.cpp:1523:80: error: 'dispatch_source_set_event_handler' was not declared in this scope
make[1]: *** [Source/JavaScriptCore/wtf/libjavascriptcoregtk_1_0_la-FastMalloc.lo] Error 1
make: *** [all] Error 2

Sarvi

Łukasz Mach

unread,
Oct 15, 2013, 4:40:25 AM10/15/13
to pyjs-...@googlegroups.com
Does anybody use pythonwebkit/pyjamas-desktop?

IIRC it's not usable and Anthony is working on make it usable, but work
is very in-progress. Am I wrong?

W dniu 15.10.2013 09:42, Sarvi Shanmugham pisze:
> --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "Pyjs.org Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to pyjs-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.


--
pozdrawiam

Łukasz Mach - lukas...@pagema.net

Kees Bos

unread,
Oct 15, 2013, 4:49:04 AM10/15/13
to pyjs-...@googlegroups.com
On Tue, 2013-10-15 at 10:40 +0200, Łukasz Mach wrote:
> Does anybody use pythonwebkit/pyjamas-desktop?
>
> IIRC it's not usable and Anthony is working on make it usable, but work
> is very in-progress. Am I wrong?

I'm not sure, but I'm still using debian/hulahop...

Sarvi Shanmugham

unread,
Oct 15, 2013, 1:18:35 PM10/15/13
to pyjs-...@googlegroups.com
Does this hulahop approach required compiling pythonwebkit?

I seem to be having trouble compiling pythonwebkit from git://git.savannah.gnu.org/pythonwebkit.git
though pywebkitgtk seemed to install fine. But from what I am reading that
is not usable?

Is there another way get going on a Mac using chrome or firefoxor safari to do pyjamasdektop ?

Lex Berezhny

unread,
Oct 15, 2013, 1:27:58 PM10/15/13
to pyjs-...@googlegroups.com
The stuff that Anthony did with webkit works fine, I've used it when working on my app.

I don't know what the status with it is as far as being released and made the default when working with pygtk. Anthony?

 - lex


Kees Bos

unread,
Oct 15, 2013, 1:54:32 PM10/15/13
to pyjs-...@googlegroups.com
On Tue, 2013-10-15 at 10:18 -0700, Sarvi Shanmugham wrote:
> Does this hulahop approach required compiling pythonwebkit?

Nope. It's not based on webkit. I wouldn't try it on other than debian.


Lex Berezhny

unread,
Oct 15, 2013, 6:02:00 PM10/15/13
to pyjs-...@googlegroups.com
I had a lengthy conversation with Anthony today about the layout and we made a bunch of updates to the wiki doc.

Everyone should take a look and provide feedback:

I will try to explain some of the decisions:

1. In an effort to keep a flatter namespace for users we decided that all of the user modules should be at the root of pyjs. So that it is possible to do things like:

from pyjs.dom import Div,Table, Tr, Td
from pyjs.ajax import AjaxComms
from pyjs.storage import LocalStorage

The above is similar to how Django has flattened their namespace.

2. Initially we had the runtimes and translator at the root as well but we felt that since it's never meant to be imported by users it shouldn't pollute the namespace. We moved it into core and then to really make the point made it a private module with an underscore (this means that "from pyjs import *" will not import _core).

3. The names of the two modules in _core are named to match up with eventual pyjs sub commands.

pyjs run app.MyApp
pyjs translate app.MyApp


Finally, one thing that came up that I don't think has been discussed before is what version of Python is stdlib supposed to target?

Another thing I would like to discuss is using the built-in python ast library and eliminating the parsing code that's currently in pyjs. Less code == less bugs. This would also make the translator code much simpler to read and work on.

 - lex 


Glyph

unread,
Oct 15, 2013, 7:12:33 PM10/15/13
to pyjs-...@googlegroups.com

On Oct 15, 2013, at 3:02 PM, Lex Berezhny <l...@damoti.com> wrote:

1. In an effort to keep a flatter namespace for users we decided that all of the user modules should be at the root of pyjs. So that it is possible to do things like:

This does look nice, but please keep in mind that "nicer names" is not necessarily worth having if the price to pay is "all of my (already quite difficult to test because of browser testing issues) code is now broken".  Having old-style aliases available would really ease the transition.

-glyph

C Anthony Risinger

unread,
Oct 16, 2013, 10:22:44 AM10/16/13
to pyjs-...@googlegroups.com
it's merged and works fine; ATM it's not the default and you have to manually enable it with ..pyjd/pyjdrc:

[gui]
engine=giwebkit

...it could pretty easily auto-detect, or just try to import all three...

it needs addEventListener to be impl'd in ctypes (or cffi, but ctypes is stdlib) to be useful -- i started this 2 nights ago and got about 1/2 thru.  i'll be at the in-laws all weekend tho and i usually get pretty good chunks of time there (since the kiddo spends time with Nana :) so my plan was to finish this weekend if possible.

the pythonwebkit stuff AFAIK is completely broken for about 2-3 years now... i thought i removed all refs to it, but maybe i only removed wiki stuff; will recheck.

--

C Anthony

C Anthony Risinger

unread,
Oct 16, 2013, 10:27:28 AM10/16/13
to pyjs-...@googlegroups.com
^^^ this, and don't bother with pythonwebkit at all... it's massively out-of-date and won't build against current libs without at least 5 patches i know of, and probably several more i don't.

TBH, i've never tried the giwebkit stuff on Mac, as i don't have access to such machine; i'm not aware of any inherent reasons preventing it from working tho... it does require GTK[23] and GObject Introspection libraries, so long as those work on a Mac it would probably work.

i plan on testing your stuff tonight tho, i just didn't quite get to it last night (though i got most of the way there).

--

C Anthony

C Anthony Risinger

unread,
Oct 16, 2013, 10:32:33 AM10/16/13
to pyjs-...@googlegroups.com
yes i agree -- this layout is just a super-high-level/coarse-grained overview of where it's heading -- my meta_path work will be merged before any of this, and that transparently handles aliasing old code.

IOW: it'll be fully back-compat and any existing code should continue to work (native or translated)
 
--

C Anthony

C Anthony Risinger

unread,
Oct 16, 2013, 10:49:43 AM10/16/13
to pyjs-...@googlegroups.com


On Tue, Oct 15, 2013 at 12:18 PM, Sarvi Shanmugham <sarv...@gmail.com> wrote:
Does this hulahop approach required compiling pythonwebkit?

I seem to be having trouble compiling pythonwebkit from git://git.savannah.gnu.org/pythonwebkit.git
though pywebkitgtk seemed to install fine. But from what I am reading that
is not usable?

Is there another way get going on a Mac using chrome or firefoxor safari to do pyjamasdektop ?

i will try out your work tonight on linux -- don't waste your time with pythonwebkit, i've already wasted my own 3 times over, and concluded it's dead long ago.

i thought i removed this stuff from the repo, but it must have been the wiki... i've updated the REDME to better reflect reality.

--

C Anthony

Sarvi Shanmugham

unread,
Oct 16, 2013, 2:00:56 PM10/16/13
to pyjs-...@googlegroups.com
Can you point me to some documentation on how to get this giwebkit compiling 
from scratch so that I can give it a go on the mac.

So far in looking for document I have been confused between
  pywebkitgtk, then pythonwebkit and no giwebkit

pywebkitgtk is a standard port I can find in my mac port repo
From what I read pythonwebkit is an old branch of webkit with luke's python changes/wrappers.

what is this giwebkit? Is it a standard part of webkit? or is it a branch of like pythonwebkit?

Sarvi

C Anthony Risinger

unread,
Oct 16, 2013, 2:18:52 PM10/16/13
to pyjs-...@googlegroups.com
On Wed, Oct 16, 2013 at 1:00 PM, Sarvi Shanmugham <sarv...@gmail.com> wrote:
Can you point me to some documentation on how to get this giwebkit compiling 
from scratch so that I can give it a go on the mac.

So far in looking for document I have been confused between
  pywebkitgtk, then pythonwebkit and no giwebkit

pywebkitgtk is a standard port I can find in my mac port repo
From what I read pythonwebkit is an old branch of webkit with luke's python changes/wrappers.

what is this giwebkit? Is it a standard part of webkit? or is it a branch of like pythonwebkit?

 * pywebkitgtk is (was?) a python binding to webkitgtk that i think uses pygtk2
 * pythonwebkit is webkitgtk + luke's patches for direct python bindings
 * giwebkit is `pyjs/runners/giwebkit.py` (a dynamic binding to a GI-enabled webkitgtk build)

...`giwebkit` is just the name i gave it, but it should work out-of-the box with any recent (last 2 yrs or so) webkitgtk build so long as it was built with `--enable-introspection`

the missing piece (addEventListener) is used pretty early so it might fail to boot, but it should be pretty easy to temporarily fake it.

from python you must be able to do this:
    from gi.repository import WebKit

you need [upstream!] GTK3 and webkitgtk (libwebkitgtk-3.0.so.*) to make it work.

--

C Anthony

Sarvi Shanmugham

unread,
Oct 16, 2013, 3:01:02 PM10/16/13
to pyjs-...@googlegroups.com
I see the following 2 choices in mac ports. From my read of pyjs/runners/giwebkit.py
I think I need the following
----------------
localhost:pyjs sarvi$ sudo port info webkit-gtk3
webkit-gtk3 @2.0.4_2 (www, gnome)
Variants:             quartz, universal, [+]video

Description:          Apple's WebKit HTML rendering library for GTK+
Homepage:             http://webkitgtk.org/

Extract Dependencies: xz
Build Dependencies:   gtk-doc, pkgconfig, autoconf, automake, libtool
Library Dependencies: glib2, bison, flex, enchant, geoclue, gobject-introspection, harfbuzz-icu, libxslt, libpng, libsecret, libsoup, mesa,
                      sqlite3, webp, xorg-libXt, gtk3, gstreamer1-gst-plugins-base
Platforms:            darwin, freebsd
License:              LGPL-2+ BSD
Maintainers:          jere...@macports.org, dev...@macports.org
------------

So It looks like I should be picking the later i.e "sudo port info webkit-gtk3"

So I can go ahead and install this and don't have to patch it before compiling right?

After I install webkit-gtk3, and lets say I have the latest pyjs sources from git.
What else do I need to do?

Sarvi
PS: If I get this to work, I promise I will do the documentation for pyjd on MacOS


 

--

C Anthony

Sarvi Shanmugham

unread,
Oct 17, 2013, 5:35:18 AM10/17/13
to pyjs-...@googlegroups.com
Well I almost got it up. keyword being almost :-)

I got webkit-gtk3 +quartz installed
I am able to do 
import gi 
from python

Had a to a little tweek in pyjd/__init__.py to add the paths pyjswidgets and pyjsaddons into sys.path

bash-3.2$ cd examples/kitchensink/
bash-3.2$ ../../mypython/bin/python KitchenSink.py 
INFO:pyjs.runners:conf:
[('runner', 'giwebkit'),
 ('home', '/Users/sarvi/.pyjd'),
 ('is_desktop', True),
 ('native_dnd', True),
 ('engine', 'giwebkit')]
init None True
INFO:pyjs.runners.giwebkit:uri:
[('scheme', 'file'),
 ('user', None),
 ('password', None),
 ('host', ''),
 ('port', 0L),
 ('path',
  '/Users/sarvi/Workspace/pyjs/examples/kitchensink/public/KitchenSink.html'),
 ('query', None),
 ('fragment', None)]
DEBUG:pyjs.runners.giwebkit:sub-frame: <WebFrame object at 0x15108a1e0 (WebKitWebFrame at 0x7ff43a874e80)>
Traceback (most recent call last):
  File "/Users/sarvi/Workspace/pyjs/pyjs/runners/giwebkit.py", line 588, in _frame_loaded_cb
    self._doc.ctx = self
  File "/Users/sarvi/Workspace/pyjs/pyjs/runners/giwebkit.py", line 409, in __call__
    self.setattr(inst, key, attr)
  File "/Users/sarvi/Workspace/pyjs/pyjs/runners/giwebkit.py", line 456, in setattr
    inst.set_data(key, attr)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gi/overrides/GObject.py", line 590, in _unsupported_data_method
    raise RuntimeError('Data access methods are unsupported. '
RuntimeError: Data access methods are unsupported. Use normal Python attributes instead

Is this something people have seen?

Sarvi Shanmugham

unread,
Oct 17, 2013, 5:50:01 AM10/17/13
to pyjs-...@googlegroups.com
Found this

C Anthony Risinger

unread,
Oct 17, 2013, 10:27:29 AM10/17/13
to pyjs-...@googlegroups.com
On Thu, Oct 17, 2013 at 4:50 AM, Sarvi Shanmugham <sarv...@gmail.com> wrote:
ah dang, thanks for the link.

i'll have to update the backend then... there wasn't a reason i used the set/get methods other than i thought they might be more stable...

if you change:


    def setattr(self, inst, key, attr):
        # hasattr() *specifically* chosen because it calls getattr()
        # internally, possibly setting a proxy object; if True, super()
        # will then properly setattr() against the proxy or instance.
        if hasattr(inst, key):
            super(self._type_gi, inst).__setattr__(key, attr)
        else:
            inst.set_data(key, attr)
            logger.debug('setattr(inst, %r, attr):\n%s', key,
                pformat([('inst', inst), ('attr', attr)]))

...to:

    def setattr(self, inst, key, attr):
        self.getattr(inst, key)
        super(self._type_gi, inst).__setattr__(key, attr)

...i think it will probably work.

the good news is you seem to be up and running! any issue from here is ours... i was a bit skeptical this would work at all, but you're way past that.

--

C Anthony

C Anthony Risinger

unread,
Oct 17, 2013, 10:33:45 AM10/17/13
to pyjs-...@googlegroups.com
On Thu, Oct 17, 2013 at 9:27 AM, C Anthony Risinger <ant...@xtfx.me> wrote:
On Thu, Oct 17, 2013 at 4:50 AM, Sarvi Shanmugham <sarv...@gmail.com> wrote:
ah dang, thanks for the link.

i'll have to update the backend then... there wasn't a reason i used the set/get methods other than i thought they might be more stable...

if you change:


    def setattr(self, inst, key, attr):
        # hasattr() *specifically* chosen because it calls getattr()
        # internally, possibly setting a proxy object; if True, super()
        # will then properly setattr() against the proxy or instance.
        if hasattr(inst, key):
            super(self._type_gi, inst).__setattr__(key, attr)
        else:
            inst.set_data(key, attr)
            logger.debug('setattr(inst, %r, attr):\n%s', key,
                pformat([('inst', inst), ('attr', attr)]))

...to:

    def setattr(self, inst, key, attr):
        self.getattr(inst, key)
        super(self._type_gi, inst).__setattr__(key, attr)

...i think it will probably work.

sorry, you need to use hasattr(), in case the attr already existed: 

    def setattr(self, inst, key, attr):
        # hasattr() *specifically* chosen because it calls getattr()
        # internally, possibly setting a proxy object; if True, super()
        # will then properly setattr() against the proxy or instance.
        hasattr(inst, key)
        super(self._type_gi, inst).__setattr__(key, attr)

...the "empty" call to hasattr is purely to trigger the creation of a proxy object, if need be.

--

C Anthony

Sarvi Shanmugham

unread,
Oct 17, 2013, 1:17:42 PM10/17/13
to pyjs-...@googlegroups.com
The second one got me pas that error and I hit the following which I suspect is related to the lack of EventListener support

DEBUG:pyjs.runners.giwebkit:sub-frame: <WebFrame object at 0x1510481e0 (WebKitWebFrame at 0x7fbae4009840)>
Traceback (most recent call last):
  File "/Users/sarvi/Workspace/pyjs/pyjs/runners/giwebkit.py", line 603, in _frame_loaded_cb
    __pyjamas__.set_main_frame(self)
  File "/Users/sarvi/Workspace/pyjs/pyjswidgets/__pyjamas__.py", line 38, in set_main_frame
    DOM.init()
  File "/Users/sarvi/Workspace/pyjs/pyjswidgets/pyjamas/DOM.py", line 83, in init
    mf._addWindowEventListener("click", browser_event_cb)
  File "/Users/sarvi/Workspace/pyjs/pyjs/runners/giwebkit.py", line 687, in addWindowEventListener
    listener = WebKit.dom_create_event_listener(cb._callback, None)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gi/module.py", line 313, in __getattr__
    return getattr(self._introspection_module, name)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gi/module.py", line 134, in __getattr__
    self.__name__, name))
AttributeError: 'gi.repository.WebKit' object has no attribute 'dom_create_event_listener'

I don't see a dom_create_event_listener in the webkit DOMWindow.idl below

But I see this below. am I way off? where did you find the dom_create_event_listener?
    // EventTarget interface
    [Custom] void addEventListener(DOMString type,
                                  EventListener listener,
                                  optional boolean useCapture);
    [Custom] void removeEventListener(DOMString type,
                                      EventListener listener,
                                      optional boolean useCapture);
    [RaisesException] boolean dispatchEvent(Event evt);

    void captureEvents(/*in long eventFlags*/);
    void releaseEvents(/*in long eventFlags*/);

I read through some of your threads/bug to WebKit/Gobject introspection about adding addEventListener below. 
Is the above what you were looking for?

Sarvi

C Anthony Risinger

unread,
Oct 17, 2013, 2:24:43 PM10/17/13
to pyjs-...@googlegroups.com

Yep, this is the remaining thing that I have to implement via ctypes... the method is defined in the underlying gobject api, but since WebKitGTK authors did not add a GNotify callback to the signature, or use a GClosure, the introspection stuff is unable to automatically generate a non-leaky binding... therefore it gets skipped altogether.

If you just change the function to skip that stuff (possibly by just `pass`ing it entirely), you should be able to run most if not all examples... event handling won't work, but it should still construct the DOM.

I plan to wrap up the ctypes stuff over the weekend... I'll be at the in-laws house with my chromebook, but VPN+SSH usually let's me work all the same.

--

C Anthony [mobile]

Sarvi Shanmugham

unread,
Oct 17, 2013, 2:53:34 PM10/17/13
to pyjs-...@googlegroups.com
I added a return to the begining of the addWindowListener function and it skipped that error
and hit another similar to the last one

I made a couple of more fixes. I got the error below
init <pyjs.runners.giwebkit.RunnerContext object at 0x10a0699d0> True
Traceback (most recent call last):
  File "KitchenSink.py", line 117, in <module>
    pyjd.setup("public/KitchenSink.html")
  File "/Users/sarvi/Workspace/pyjs/pyjs/runners/__init__.py", line 68, in setup
    listener()
  File "/Users/sarvi/Workspace/pyjs/pyjswidgets/pyjamas/History.py", line 109, in init
    hash = wnd().location.hash
  File "/Users/sarvi/Workspace/pyjs/pyjs/runners/giwebkit.py", line 408, in __call__
    return self.getattr(inst, key)
  File "/Users/sarvi/Workspace/pyjs/pyjs/runners/giwebkit.py", line 413, in getattr
    attr = impl(inst, key)
  File "/Users/sarvi/Workspace/pyjs/pyjs/runners/giwebkit.py", line 423, in getattr_gi
    if inst.get_data(key) is None:
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gi/overrides/GObject.py", line 590, in _unsupported_data_method
    raise RuntimeError('Data access methods are unsupported. '
RuntimeError: Data access methods are unsupported. Use normal Python attributes instead

And made a change to hasattr() along the same lines as your suggestion above.

Then I got the following
  File "/Users/sarvi/Workspace/pyjs/pyjs/runners/giwebkit.py", line 438, in getattr_w3
    attr = self._custom[key].bind(key)
  File "/Users/sarvi/Workspace/pyjs/pyjs/runners/giwebkit.py", line 360, in bind
    return types.MethodType(cls(key), None, owner)
  File "/Users/sarvi/Workspace/pyjs/pyjs/runners/giwebkit.py", line 328, in __init__
    Soup.URI.new()
TypeError: new() takes exactly 1 argument (0 given)

I just changed that to take Scoup.URI.new('http://www.google.com')

and then I hit this
  File "/Users/sarvi/Workspace/pyjs/pyjs/runners/giwebkit.py", line 438, in getattr_w3
    attr = self._custom[key].bind(key)
  File "/Users/sarvi/Workspace/pyjs/pyjs/runners/giwebkit.py", line 360, in bind
    return types.MethodType(cls(key), None, owner)
  File "/Users/sarvi/Workspace/pyjs/pyjs/runners/giwebkit.py", line 332, in __init__
    doc = app._doc
NameError: global name 'app' is not defined

When I was looking through, I am not sure I understand how this code has been working so far, coz "app" is not 
defined gloablly.

What am I missing. 
I could wait for you to finish up the addEventListener, but I suspect thats not gonna address any of this.
So let me know if it is helpful for me to pursue this.

Sarvi

C Anthony Risinger

unread,
Oct 17, 2013, 3:28:20 PM10/17/13
to pyjs-...@googlegroups.com
so i was looking into this... and i have absolutely no idea what changed, webkit or gobject-introspection, but AFAICT... add_event_listener is NOW SUPPORTED OUT OF THE BOX.

i'm going to spend a few minutes on this so i'll ping when done... go ahead and stand by until then, i'll let you know once it runs on my machine.

--

C Anthony

C Anthony Risinger

unread,
Oct 17, 2013, 5:16:24 PM10/17/13
to pyjs-...@googlegroups.com
ok, some success...

the goog news is add_event_listener REALLY does work, the problem is the handler doesn't recieve any args.  i know what the problem is, and i'm pretty sure there is a solution using PyGI's overrides system, but i'll have to look at that later... FTW, i somewhat described the issue last year, here:


...it relates to the fact that a GCallback (before casting) doesn't receive any args, therefore PyGI doesn't send any.

RE: the `app` issue, honestly i don't know how that worked before... more than likely i changed the global from app -> context at the last second and never tested it before committing, but i promise you, this thing worked at one point :)

so, even though event handling is busted, and will cause a segfault, you should be able to do this:

# cd examples/kitchensink/
# ../../bin/pyjd KitchenSink.py

...and see the example in all it's glory. you must be in the proper directory else it won't find the template HTML file. mousing over the window will lead to a segfault until i figure out how to tell PyGI which args to expect for a handler... i know it can be done by modifying the annotation in the source (as i demonstrated in the link above), but obviously we don't want to do that because then you have to recompile webkit for a very stupid reason.

i may have time tonight to look into this, otherwise i'l have to punt until the weekend, but feel free to explore until then! this is probably the final hurdle to a fully out-of-the-box solution for Linux (and apparently MacOS!)

--

C Anthony

Sarvi Shanmugham

unread,
Oct 26, 2013, 10:52:36 PM10/26/13
to pyjs-...@googlegroups.com
Was the addlistener problem fixed for the pyjamas-desktop with your recent commits?
Are you able to run examples from pyajamas-desktop using giwebkit?

I was able to run examples/helloworld
sarvi-mac:helloworld sarvi$ ../../lpython/bin/python HelloWorld.py

But the KitchenSink still fails for the addlistener

sarvi-mac:kitchensink sarvi$ ../../lpython/bin/python KitchenSink.py 
INFO:pyjs.runners:conf:
[('runner', 'giwebkit'),
 ('home', '/Users/sarvi/.pyjd'),
 ('is_desktop', True),
 ('native_dnd', True),
 ('engine', 'giwebkit')]
init None True
INFO:pyjs.runners.giwebkit:uri:
[('scheme', 'file'),
 ('user', None),
 ('password', None),
 ('host', ''),
 ('port', 0L),
 ('path',
  '/Users/sarvi/Workspace/pyjs/examples/kitchensink/public/KitchenSink.html'),
 ('query', None),
 ('fragment', None)]
DEBUG:pyjs.runners.giwebkit:sub-frame: <WebFrame object at 0x149894b40 (WebKitWebFrame at 0x7fcc2a023c40)>
Traceback (most recent call last):
  File "/Users/sarvi/Workspace/pyjs/pyjs/runners/giwebkit.py", line 608, in _frame_loaded_cb
    __pyjamas__.set_main_frame(self)
  File "/Users/sarvi/Workspace/pyjs/pyjswidgets/__pyjamas__.py", line 38, in set_main_frame
    DOM.init()
  File "/Users/sarvi/Workspace/pyjs/pyjswidgets/pyjamas/DOM.py", line 83, in init
    mf._addWindowEventListener("click", browser_event_cb)
  File "/Users/sarvi/Workspace/pyjs/pyjs/runners/giwebkit.py", line 692, in addWindowEventListener
    self._wnd.add_event_listener(event_name, listener, False, None)
  File "/Users/sarvi/Workspace/pyjs/pyjs/runners/giwebkit.py", line 410, in __call__
    return self.getattr(inst, key)
  File "/Users/sarvi/Workspace/pyjs/pyjs/runners/giwebkit.py", line 421, in getattr
    inst.__class__.__name__, key))
AttributeError: 'DOMDOMWindow' object has no attribute 'add_event_listener'

Sarvi Shanmugham

unread,
Oct 28, 2013, 2:55:32 PM10/28/13
to pyjs-...@googlegroups.com
Hi Anthony,
     I've been reading up on how to fix this add_event_listener problem and I came across a thread from you on the topic
Yet I can't seem to find any documentation on this add_event_listener API

On the other hand I found this
which seems to be using connect() to add the listeners to both the GTK level window objects as well
Webkit objects link links, docs, etc. I also noticed while debugging the Window and Document objects in runners.giwebkit 
they have connect() API in them.

I am gonna look at fixing this later this evening. Was just hoping you could throw some context on why add_event_listener and why not connect() ?

Sarvi

C Anthony Risinger

unread,
Oct 28, 2013, 6:34:23 PM10/28/13
to pyjs-...@googlegroups.com
On Mon, Oct 28, 2013 at 1:55 PM, Sarvi Shanmugham <sarv...@gmail.com> wrote:
Hi Anthony,
     I've been reading up on how to fix this add_event_listener problem and I came across a thread from you on the topic
Yet I can't seem to find any documentation on this add_event_listener API
 
yeah for the most part there isn't much info out there :( the GObject stuff is pretty much 1-to-1 with DOM spec though, except using GObject naming convention, ie. underscores vs. .

On the other hand I found this
which seems to be using connect() to add the listeners to both the GTK level window objects as well
Webkit objects link links, docs, etc. I also noticed while debugging the Window and Document objects in runners.giwebkit 
they have connect() API in them.

those objects have a connect() method IIRC because they are high-level obects that interact with other GTK3 objects, but i don't think everything does.
 
I am gonna look at fixing this later this evening. Was just hoping you could throw some context on why add_event_listener and why not connect() ?

there is some race problems due to events coming from GTK3 instead of WebKit, though to be honest, i can't expand much more than that.  additionally, i believe the GTK3 connect() stuff would require all objects to register for all events ahead of time(!)... IIRC this was a limitation of the GTK3 framework that "might be addressed" at some point.  if you search the pyjamas-dev archives you can probably dredge up at least 10-20 pages of Luke rampaging about it, among other related things ;)

i'm actually on my way out of the office so i hope this isn't too terse, i mainly wanted to catch you early so you don't waste any time on this... because as of:


...we no longer have a problem :) after i tried to get it working the other day, and discovered it was supposedly "fixed", i sort of raged on them myself:

 
...but lo and behold, the patch we need was merged 4 days later, so the next release should have everything we need to implement this runtime using vanilla upstream sources, and hence should soon work properly in all modern distros (and probably Mac too!).

-- 

C Anthony
Reply all
Reply to author
Forward
0 new messages