Hi Daniel.

I did some experiments calling python methods from javascript code.
I think you need wrap your method callback into anonymous function (see 
setTimeout example)

Here are the examples:

from __pyjamas__ import JS


class Cls():
  def __init__(self, name):
    self.name = name

  def sum(self, a, b):
    print "Met from %s instance" % self.name
    return a + b

  def touch(self):
    print "Touch called from %s instance." % self.name


if __name__ == '__main__':
  c = Cls("foo")
  res = 0

  # This works
  res = JS("""
    @{{res}} = @{{c}}.sum(5,10)
    """)
  print res

  # This works
  JS("""
    @{{c}}.touch()
    """)

  # This don't work
  JS("""
    setTimeout(@{{c}}.touch, 3000)
    """)

  # This works 
  JS("""
    setTimeout(function(){@{{c}}.touch()}, 3000)
    """)




-- 



Reply via email to