Playing with Python

From OESF

(Difference between revisions)
Jump to: navigation, search
(An Analysis)

Line 71:

Line 71:

I must say I never thought that differences between Sharp ROMs and OpenZaurus might present bigger problems than differences between Zaurus models
I must say I never thought that differences between Sharp ROMs and OpenZaurus might present bigger problems than differences between Zaurus models
 +
 +
* On the 760 keyboard the Enter and OK keys are also equivalent, and generally map to a dialog's OK/Yes button... but not on this one. Mostly it seems to call the "modify data type list" dialog, although it depends where the focus is.
 +
 +
* There are other workarounds though : kham's idea works (nice call kham, see below !), and also you can tab your way to the OK button itself (4 tabs from the "output format" field, or 2 shift-tabs from the first field) and press Enter. But I agree it's strictly for emergencies only
 +
 +
Well, dunno if it's really trivial, but this one doesn't work here :
 +
 +
# ipkg install treeline_0.8.1_sharp_arm.ipk
 +
zcat: stdin: unexpected end of file
 +
ipkg_install_file: ERROR unpacking control.tar.gz from treeline_0.8.1_sharp_arm.ipk
 +
 +
BTW, that's the exact same error I received many times while trying to build my own ipk from the OZ original, which is why I ended up installing by hand. So there must be another difference somewhere...
 +
 +
==Mo' Fun==

Revision as of 18:08, 17 July 2005

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. You will need the developer version of the port to follow the conversation.

Contents

Introduction

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.

Installation

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 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 :-)

Look Ma! It runs!

Here is the main window, empty.

It looks just fine as a screenshot here, but believe me, on the Z those letters and icons are *SMALL*... yes... smaller than usual, even

the General Options dialog

This is where the origins of zenyatta's port show through (QVGA, portrait).

The results on a landscape VGA, obviously, look a little lopsided... but still perfectly workable :-)

the File Options dialog

A little sparse, perhaps, but it works too, and you can't miss the buttons

A real problem

The only thing I've found that is not workable on the Z is the "Configure Data Types" dialog in its present state.

The top and bottom parts are off-screen, along with a couple of fields and the OK/Cancel buttons...

On my 760 the Cancel button on the keyboard dismisses the dialog, but the OK button does not validate it. So as far as I can tell, you can't *define* a new record type directly on the Zaurus version.

Of course, you can run the app on your desktop PC too (Windows/Linux), so you can organize your data types there, then copy over the .trl file(s), so that doesn't mean you can't put treeline to good use on the Z !

Maybe someone familiar wih Qt/QPE could turn that dialog into a vertically scrolling one like the General Options above ?

An Analysis

Two of the problems you mention are very easy to solve or work around:

  • The Enter key on the keyboard is equivalent to the OK key, at least on the 5500. That allows me to define new data types even on the Zaurus (although it is pure torture). I have added this workaround to the documentation.
  • If the biggest difference between Sharp and OZ packages is the archiving program used, it's very trivial to create both versions. I have now added a package to the download area that will hopefully work with Sharp ROMs. I have no way of testing that, of course. There may be dependency problems if python packages on the Sharp side are structured differently than under OZ. It might have to be installed without dependency checking.

I must say I never thought that differences between Sharp ROMs and OpenZaurus might present bigger problems than differences between Zaurus models

  • On the 760 keyboard the Enter and OK keys are also equivalent, and generally map to a dialog's OK/Yes button... but not on this one. Mostly it seems to call the "modify data type list" dialog, although it depends where the focus is.
  • There are other workarounds though : kham's idea works (nice call kham, see below !), and also you can tab your way to the OK button itself (4 tabs from the "output format" field, or 2 shift-tabs from the first field) and press Enter. But I agree it's strictly for emergencies only

Well, dunno if it's really trivial, but this one doesn't work here :

 # ipkg install treeline_0.8.1_sharp_arm.ipk
 zcat: stdin: unexpected end of file
 ipkg_install_file: ERROR unpacking control.tar.gz from treeline_0.8.1_sharp_arm.ipk

BTW, that's the exact same error I received many times while trying to build my own ipk from the OZ original, which is why I ended up installing by hand. So there must be another difference somewhere...

Mo' Fun

Personal tools