obbyPY
PYJAVAS PROJECT

../index.htm,sametab

The PYJAVAS PROJECT aims to get Python and Javascript to work together.
The idea is that there are a number of things which Javascript cannot do easily or cannot do at all.
So Python does the donkey-work and passes its data to Javascript (in the browser) on demand.

Did a couple of prototypes which worked, but they had at least one serious limitation.
Today (18/12/2024), I solved the problem(s) with a slightly new approach, and it worked immediately like magic! I was amazed!

What I have now is a PYJAVAS PROJECT DEMO. It uses the listSort app in Python (see https://www.bobbypy.com/listSort_HELP.htm) and saves its output (whenever it is asked, in the blink of an eye) to a webpage in Google Chrome.

(It can be made to work with Firefox as well, but I would need to ask the operator to open up a Linux local server - it is not easy to do that programmatically without problems. In Javascript, Chrome does most of the things that Firefox can do, so at least for now, it is not worth bothering about.)

In practical terms with PYJAVAS, this means that I can now create offline PC apps with (almost) all the Python and Javascript resources combined. (By "offline", I mean "without necessarily using the Internet.)

Hopefully, my programming life in 2025 will be a lot more tranquil than it has been in 2024!
PYJAVAS DEMO INSTALLATION
If you don't have it installed already, the Demo requires Google Chrome STABLE. It can be found in the LMDE Repository.
Apart from that, nothing else is required.
HOW IT WORKS
As with the other Python apps at this site, the ZIP file you download, once extracted, will show you a folder containing a PY Runner and other files required for the Demo:
Double-clicking on the Runner file will open it, and you will be presented with the only Python script in the folder, so click on that.
Initially, you are presented with the Google Chrome browser that contains a simple Javascript app.

Note the iconified Python app (listSort) in the top left-hand corner. Click on this immediately to fully display listSort, and also on following occasions when you wish to return to Python.

You might also note that the GNOME Terminal has opened. Leave it open until you have finished with the Demo.

So clicking on the Python logo will cause the listSort app (re-named as 'python.py') to be maximized:
If you are already familiar with the listSort app (available in the Python Apps section of this site), you will note two differences. Apart from the Python logo in the top left-hand corner, you now have a Javascript logo in the top right-hand corner. More will be said about this. For now, all you need to know is that the logo buttons enable you to switch between the Python app and the Javascript app in Google Chrome.
When your output list is ready, click on the Javascript SEND button (top right).
The magic will then occur:
BAM!

There is the data from Python being shown without further ado in the Chrome browser!
If you are not already familiar with the operation of the listSort app, click on the HELP button at the top for a full explanation. Briefly, the app sorts lists of lines with dates in them into chronological order. The options on the left determine the form of date to be used in the output list. Lists can be typed or uploaded from the HD. You can upload an existing list (a text) or you can grab the names of files within a folder if the names contain dates. To practise with initially, you can get an example list (text) for upload HERE.
Googe Chrome
STABLE
(required)
WHAT THE DEMO SHOWS
This demo shows that it is perfectly possible to transfer data between Python and Javascript with no operator intervention except the press of a button. The Javascript app does not need to be restricted to a simple display of data as shown here. Any amount of processing can be achieved subsequently, and the data transferred can be almost anything you like. In other words, the normally-restricted Javascript now has access to the entire PC file system, plus all the processing libraries available in Python. That's not such a small deal!
PERSPECTIVE
This opens up the immediate possibility of developing what might be known as

PYJAVAS "DUAL APPS" for PC offline use.

It remains to be seen what this will lead to in 2025 onwards.
(required)

pyjavas_demo.zip,newtab

Download