W dniu poniedziałek, 18 czerwca 2012 10:10:38 UTC+2 użytkownik C Anthony
Risinger napisał:
>
> [... ]
that sounds like a sound plan; you can embed JS('var x =
> function(){}') blocks into your python, or IIRC, use something like:
>
> from __javascript__ import my_dispatcher
>
Correct me if I'm wrong, but pyjs js code is imported into IFRAME context,
so my_dispatcher has to be object/function in IFRAME, not in document,
right?
>
> ... to access to javascript identifiers. also take a look at how the
> stdlib and _pyjs.js use @{{python-identifier}} to embed python objects
> into JS() blocks, so maybe something like (untested):
>
> def py_dispatcher(str_val, int_val):
> // do something ...
>
> JS('''
> $pyjs_dispatcher = function($string, $integer){
> @{{py_dispatcher}}(@{{str}}($string), @{{int}}($integer))
> }
> ''')
>
> ... then you call $pyjs_dispatcher from your javascript code (with
> primitive args), and it should properly call your python function.
>
.... so, he shoulsn't call $pyjs_dispatcher, but
document.frames[0].$py_dispatcher ...
Am I wrong? I think not - I'm facing similar problem, and yesterday I tried
to do something similar (well, opposite, access HTML objects from pyjamas
code). And I had to do
from __javascript__ import window
....
window.parent.XXXX (where XXX is javascript identifier in main document
code).
regards
Maho