Hello:
Long time since the last time I used pivot (back when it was in
incubation), now I've got a new project where Pivot will come in handy,
however I'd like to try using python for UI logic instead of javascript,
however I'm having some problems with this:
Following the Scripting tutorial in the pivot homepage, I tried to
port the code to use it with python, however I get this exception when
running the code:
javax.script.ScriptException:
sun.org.mozilla.javascript.EvaluatorException: missing ; before
statement (<Unknown source>#2) in <Unknown source> at line number 2
from org.apache.pivot.wtk import Prompt
def buttonPressend(button):
Prompt.promp("PYTHON", button.getWindow())
This is the bxml source:
<Window title="Hello BXML!" maximized="true"
xmlns:bxml="http://pivot.apache.org/bxml"
xmlns="org.apache.pivot.wtk">
<BoxPane orientation="vertical" styles="{padding:6}">
<PushButton buttonData="Click Me!">
<buttonPressListeners>
from org.apache.pivot.wtk import Prompt
def buttonPressend(button):
Prompt.promp("PYTHON", button.getWindow())
</buttonPressListeners>
</PushButton>
</BoxPane>
</Window>
The above is trying to run the code using the javascript engine, so
I tried to put this in an external file and include it in bxml source
like this:
<Window title="Hello BXML!" maximized="true"
xmlns:bxml="http://pivot.apache.org/bxml"
xmlns="org.apache.pivot.wtk">
<bxml:script src="test.py" language="python" />
<BoxPane orientation="vertical" styles="{padding:6}">
<PushButton buttonData="No, Click Me!"
ButtonPressListener.buttonPressed="buttonClicked(arguments[0])"/>
</BoxPane>
</Window>
test.py:
from org.apache.pivot.wtk import Prompt
def buttonClicked(button):
Prompt.promp("PYTHON", button.getWindow())
But then I get this exception:
javax.script.ScriptException: sun.org.mozilla.javascript.EcmaError:
TypeError: buttonClicked is not a function, it is object. (<Unknown
source>#1) in <Unknown source> at line number 1
buttonClicked(arguments[0])
Which tells me it's still trying to use the javascript engine to
run the code, how can I tell pivot to use a different engine? The
"language" attribute for the tag <bxml:script> seems to do nothing.
Thanks in advance!
Edgar Merino