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
https://lists.webkit.org/pipermail/webkit-gtk/2012-February/000936.html
Yet I can't seem to find any documentation on this add_event_listener API
On the other hand I found this
http://python-gtk-3-tutorial.readthedocs.org/en/latest/introduction.html
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
On Saturday, October 26, 2013 7:52:36 PM UTC-7, Sarvi Shanmugham wrote:
>
> 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'
>
>
>
>
> On Thursday, October 17, 2013 2:16:24 PM UTC-7, C Anthony Risinger wrote:
>>
>> On Thu, Oct 17, 2013 at 2:28 PM, C Anthony Risinger <[email protected]>wrote:
>>
>>> On Thu, Oct 17, 2013 at 1:53 PM, Sarvi Shanmugham <[email protected]>wrote:
>>>
>>>> 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.
>>>>
>>>
>>> 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.
>>>
>>
>> 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:
>>
>> https://bugs.webkit.org/show_bug.cgi?id=77835#c16
>>
>> ...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
>>
>
--
---
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.