B4J Library jPython

This library allows you to use python in B4J (based on jython)
Similar to the jInvokeNashorn library in jScriptEngine topic

Can use a string as a script or a file in Objects/scripts/

Attached is the library - jPython.zip
test b4j project - python testing.zip

Simple examples are included in the source.

The python zip is a tad large so won't upload
Here's a link to it - Removed

Added a new example py script - it shows how to
a, interact with b4j
b, create new controls and add to mainform (either by passing mainform.rootpane or not)
c, add event handling for controls (calls a routine in the b4j app)

(Obviously if your app package is not b4j.example.main - edit accordingly)

jPython(no jython jar).jar is just the library without the jython.jar included

if you use that you need to d/load 'jython-standalone-2.7.0.jar' (google jython) and place in libraries folder.

**** see post 7 ******

****** UPDATE 11/12/15
jPython lib
This needs the full path to the script file

py.InitInvocable("myscript.py") becomes py.InitInvocable("./myscript.py") if the script is in current directory
The library will no longer look in /objects/scripts for the file

Added library source


*** Added jython lib.zip
Requires jython.jar to be added with #AdditionalJars
(currently only works in debug mode - still testing to find reason why)
Ok - sorted it now to work in release
There is a new function - pythonLibraries - point this to the library folder
usually C:/jython2.7.0/lib

Latest version is 1.6
 

Attachments

  • python testing.zip
    18.6 KB · Views: 521
  • python testing 2.zip
    20.4 KB · Views: 500
  • jPython (no jython jar).zip
    2.6 KB · Views: 464
  • jPython lib.zip
    2.7 KB · Views: 527
  • jPython lib source.zip
    885 bytes · Views: 456
  • jython lib.zip
    3.6 KB · Views: 468
  • jythonlibraryV1.6.zip
    3.9 KB · Views: 478
Last edited:

liulifeng77

Active Member
Licensed User
Longtime User
I'm very interested in your libray.
my question is:
if I import the third libray in the .py file(eg. from docx import document), it will show the error message. how to sovle it ,thanks !
 

davidcr85

Member
I'm reviving a fairly old thread but I think it is necessary because the query is specifically directed to the use of this Jpython library
It is possible to use it in B4A ???
 

DonManfred

Expert
Licensed User
Longtime User
Top