Goetz Schwandtner's PythonS60 Experiments

On this page some of my experiments with Python using the version for the Nokia Series 60 platform are introduced. All these programs come as python sources and as free software, copyright by Goetz Schwandtner. For the Python interpreter (PyS60), see the links section.

Project 1: simple spigot algorithm

Rabinowitz [4] published an algorithm to calculate the digits of π. In spigot.py his Pascal program is implemented in a python class together with a spigot algorithm for the base e for the base of the natural logarithm, derived from his paper.

spigot.py may be run as a standalone script on PyS60, but may also be imported as a module providing the classes SpigotPi and SpigotE into any Python interpreter with version at least 2.2. In the standalone version on PyS60, just select the algorithm, enter the number of digits and then select Options->Save. The results will also be written to the console for reviewing after the program run.

Download:
spigot.py (© Copyright Goetz Schwandtner 07-2006)

Project 2: Tricky mirrors

This game was intended as a proof of concept: A game completely developed using only a smartphone. The game is fully playable and completable, but it is still in a proof of concept stage offering only three levels. But you can create own levels by implementing them in the Gamefield class.

This game is influenced by the games Oxyd and Mirror Magic. Each level of the game consists of a rectangular grid containing different elements: Lasers, mirrors, targets and more. The aim is to orient the mirrors to hit the targets with a laser beam and destroy them, where fixed and automatic components may interrupt your plans.

For more details, see the game homepage.

News on 2008-08-19: Version 1.0 released!

Project 3: AppKill

This is a frontent for the appswitch module [5] and provides a basic task manager functionality: List apps (with or without hidden apps), switch to an application, kill an application.

The kill command be used with extreme caution. With the kill command it is possible to kill the telephone app ("Telefon") and after that the power button menu will be inoperative. To switch off the device you will then need special software or simply remove the battery. So: Don't try this at home, kids!

The AppKill script is ready to be executed as standalone application, e.g. by creating an installer with using the Ensymble [6] command:
ensymble.py py2sis appkill.py appkill.sis

Download:
appkill.py (© Copyright Goetz Schwandtner 12-2006)

Project 4: PasTriang

A nice little demo application showing Pascal's triangle in a short object oriented implementation. Once started, the script displays the triangle as colored boxes, and the colors can be changed from uniform to colors depending on the number modulo a constant k. Choosing, e.g., k=2 all even numbers (0 modulo 2) are displayed in red and all odd numbers (1 modulo 2) are displayed in blue, resulting in a Sierpinski Sieve (see [7]). The program was developed on-device using the nice Ped IDE [8]

Keyboard help:

left/right resize triangle
up/down change modulus k
0 toggle numbers (labels)
# toggle status display (size, modulus)
Download:
pastriang.py (© Copyright Goetz Schwandtner 01-2008)
pastriang screenshot

Project 5: Roman Numerals

A short hack of two functions converting Roman numerals to decimal numbers (toDecimal) and decimal numbers to Roman numerals (toRoman) for numbers n in the range 0<n<5000.

Usually, Roman numerals are restricted to at most three occurrences of one of the symbols I, X and C. In our conversion functions we allow at most four consecutive occurrences of the symbols I, X, C and M, as used in some occasions. For the subtractive version of numerals, only the next smaller numeral from the set {I, X, C} is allowed, e.g. IV (=4) and CMXDIX (=999) are permissable, while VX, IC and IM are not.

Download:
romans.py (© Copyright Goetz Schwandtner 02-2008)

Project 6: Quicknote

This program displays a "yellow sticky note" in the upper part of the screen. Once started, the note is shown throughout all programs, until the user puts the program to foreground using the devices task manager and exits the program or hides the note. The menu entries of the program are straightforward: Show and Hide switch the note display on and off, while Set note lets you enter the text to display. Due to the restrictions of the PyS60 dialogs, only one (not very long) line of text can be entered, which will automatically be wrapped in the display.

While this application has some use of its own, especially when built as standalone app, it is also a nice example for some PyS60 topics:

Download:
Quicknote.py (© Copyright Goetz Schwandtner 05-2008)

References and Links:

  1. Python interpreter and loads of documentation: www.python.org
  2. PyS60: Python for Symbian OS Series 60
  3. PyS60 Tutorial by Jürgen Scheible
  4. Stanley Rabinowitz, Stan Wagon: A Spigot Algorithm for the Digits of pi. American Mathematical Monthly, Vol 102 No 3 (Mar 1995) pp 195-203
  5. Appswitch module: For S60v2 (not tested by me), for S60v3
  6. Ensymble: Standalone installation of PyS60 scripts on S60v3 and much more
  7. Sierpinski Sieve
  8. Ped: A full-featured Python IDE for Nokia S60 platform.

Disclaimer:

As usual, I will take no responsibilities for problems connected with the use of my programs. For me, they have been working fine, but that does not mean that there could not be problems, bugs etc.