Playing with Python
This is an extract of an conversation regarding Python and an attempt by fpp to fix a few Python issues surrounding it. The original conversation can be found here
Treeline is an app written in the python language.
Python is an interpreted language, not compiled like C or C++, so to run apps written in it you need to have the python interpreter installed. Also, Treeline is a graphical app, and to make use of the Z's QTopia interface it needs a special library, PyQt, to access it from python code.
If you're not already a Python user, and have enough memory available on your Z (SD/CF), the simplest way to acquire these is to use the ready-made image by Kopsis : it will cost you about 50 megs of space, but is really easy to install and gets you everything you need (and more :-) all in one go.
If you're low on resources, you can install just the relevant bits with traditional IPKs, either from Riverbank's ports (the makers of PyQt), or mickeyl's arm-python distribution. All the relevant links can be found in a couple of threads over in the Python forum.
For tinkerers who would like to hack the code and improve zenyatta's port, they will need to know or learn three things :
- the python language itself,
- Qt's way if building GUI apps and its API (through PyQt),
- the particular quirks and limitations of QPE, the variant/subset of Qt used by Sharp to create Qtopia.
Here, early on, is where most users of the original Sharp ROMs, and compatible derivatives (like the excellent Cacko ROMs), will encounter a problem.
Zenyatta built his treeline_0.8.1_arm.ipk in an OpenZaurus environment, which is almost, but not quite, totally unlike Sharp's. In particular, they both call their packages IPKs but have different ideas of what should be inside.
Sharp's IPKs are really renamed .tgz files (TAR archives compressed with gzip). OZ compresses with the 'ar' program instead of gzip, so Sharp's installer refuses to handle those packages. Note: mickeyl's arm-python packages pose the same vexing problem to non-OZ users.
So what to do ?
One way is to upgrade your original package manager : somewhere in the ZUG feed you will find a replacement to ipkg (both graphical and command-line) that supposedly handles both formats equally well (I don't doubt it, but I haven't tried).
Another quick-n-dirty way, if you're not afraid of the Linux shell and the command-line, is to open the console, and uncompress your treeline_0.8.1_arm.ipk with 'ar', then untar the resulting file. This will yield three files, one - the biggest - called data.tgz. If you gunzip/untar this one, you get a directory tree starting with 'opt' and containing all the needed files for Treeline, so it's just a matter of copying this to / (as root), and it should work.
Note 1 : using this method I do get a TreeLine icon in the Apps tab after rebooting Qtopia, but it doesn't work. For now I just open the console and run 'treelinelauncher'.
Note 2 : when doing this you may see that the program complains at startup that something is amiss with Unicode, and please RTFM. The README says to copy the sitecustomize.py file from the source directory to the site-packages directory in your Python installation. When you do this, the message goes away. But the icon still doesn't work
In the screenshot below you also see error messages (tracebacks in python) printed when you select some menu items that don't work on the Z. Contrary to VB or othe languages, the app just trudges on regardless :-)