folder structure:
example1:
    public/jquery.js
    jquery.js
    example.py
       
run:
../pyjs-pyjs-07f54ad/bin/pyjsbuild example.py

example.py:
---
from __javascript__ import jquery.js
# Create a simple widget class
class ClickWidget(object):
    def __init__(self, base_elem):
        # Add some initial HTML code
        base = jquery(base_elem)
        base.html('<div class="clickme">Click me!</div>'
                  '<div class="change">Then this will change.</div>')
        self.output_div = jquery('.change', base)

        # Bind the click event to the on_click method
        jquery('.clickme', base).bind('click', self.on_click)

    # This is our click event handler
    def on_click(self, event):
        self.output_div.append(' It clicked!')

# Install our widget
widget = ClickWidget('body')
---

I get:
pyparser.parse.ParseError: bad input: type=23, value='.', context=('', (1, 
33))

when using:
---
import jquery.js
# Create a simple widget class
class ClickWidget(object):
    def __init__(self, base_elem):
        # Add some initial HTML code
        base = jquery(base_elem)
        base.html('<div class="clickme">Click me!</div>'
                  '<div class="change">Then this will change.</div>')
        self.output_div = jquery('.change', base)

        # Bind the click event to the on_click method
        jquery('.clickme', base).bind('click', self.on_click)

    # This is our click event handler
    def on_click(self, event):
        self.output_div.append(' It clicked!')

# Install our widget
widget = ClickWidget('body')
---

I get:
TypeError: (void 0) is not a function

so like you mentioned it looks like using only "import jquery.js" is the 
way to go, but leaving me with some new error i did not understand.

i started reading all pyjs sources again and it looks like
that in the "pyjs book"  in chapter "Javascripting" is a short passage
that is describing how to import a javascript libary:
" import jsdicttest.js # YUK!!! "

but the book seems outdated is days to build: wiht pyjs.py and build.py
can you still recommend the book for beginners?

and if someone is looking for using the pyjs compiler without the rest of 
pyjs 
i'm not sure this person will look under "javascripting"

there is also another question bothering me:
is "from __javascript__ import ... " still a valid usage? 

in the link example there is a note:
# Import jQuery. Note: JavaScript variables have to be
# imported from the fake __javascript__ module.

after all debugging and reading today i'am not sure about that
or this is at least not consistent, because:
from __javascript__ import jquery does not work and 
when i write a python program with just:
alert('Hello World')
and compile it with pyjsbuild it is working without 
from __javascript__ import alert

so at the and of the day pyjs still confuses me ;-D

-- 



Reply via email to