Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Archived:Python on Symbian Technical Overview

From Wiki
Jump to: navigation, search

Archived.pngAquivado: Este artigo foi arquivado, pois o conteúdo não é mais considerado relevante para se criar soluções comerciais atuais. Se você achar que este artigo ainda é importante, inclua o template {{ForArchiveReview|escreva a sua justificativa}}.

All PySymbian articles have been archived. PySymbian is no longer maintained by Nokia and is not guaranteed to work on more recent Symbian devices. It is not possible to submit apps to Nokia Store.

Article Metadata
Compatibility
Platform(s): Symbian (S60 2nd, 3rd, 5th Edition, Symbian^3)
Article
Created: hamishwillee (07 Jan 2011)
Last edited: hamishwillee (08 May 2013)

This article provides an overview of Python on the Symbian platform. It explains the factors that differentiate Python from other programming languages, where you get the files needed to develop on Python on the Symbian platform, and where you can find other key resources.

Contents

Introduction to PySymbian

Python is a general-purpose object-oriented programming language. It is an easy-to-learn but powerful scripting language whose design philosophy emphasizes productivity and code readability. Many common tasks can be achieved in just a few lines of code by using its extremely comprehensive standard library. This notion is captured in the ‘batteries included’ philosophy, which focuses on the out-of-the-box abilities of the Python distribution.

Python has an open-source, community-based development model that is managed by the Python Software Foundation. PySymbian is managed as a separate open-source entity, largely bankrolled by Nokia – but a large community effort has grown around it.

PySymbian, better known as PySymbian, is Nokia’s port of the Python runtime to the Symbian platform. As such, it uses the same Python core language and idioms. The PySymbian distribution consists of a subset of the standard Python libraries and some newly developed libraries that target mobile-specific APIs, for instance, the sending of SMS, reading contacts or reading orientation from accelerometers. PySymbian serves as a powerful tool for the rapid development of mobile applications and utilities and is also put to good use in the rapid prototyping of sophisticated applications.

PySymbian differs from Flash Lite and Java ME, in that it can be extended using C/C++ by installing DLL extensions. This is an important consideration because you can work around any platform features not directly available in Python by creating a relevant C++ extension and distributing that with your application.

Ease of Use

The main characteristic of Python is its ease of use. Its simple syntax and APIs tend to enable simple tasks to be achieved with clarity and very few lines of code.

For instance, the following code snippets show a full program for obtaining a list of SMS messages in the inbox of an S60 device and for setting the orientation of the application to portrait, respectively.

import inbox
box = inbox.Inbox()
messages = box.sms_messages()
import appuifw
appuifw.app.orientation = ‘portrait’

Its simple and straightforward syntax can be picked up quite easily and its enforcement of indentation helps to improve the readability of code. Anecdotally, many developers are impressed with the productivity improvements achieved with PySymbian as compared with Symbian C++.

Although Python is commonly championed for the rapid prototyping of applications, there is no real restriction on what kind of application can be implemented with it. Indeed, you can build many types of applications using Python, including utilities, games, location-based services and so on (see the sample applications).

As far as efficiency is concerned, Python provides a comprehensive collection of optimized containers, plus the methods to manipulate them. For many tasks, code execution in PySymbian is comparable to the execution of native Symbian C++ code.

Although PySymbian is very rich in APIs, having modules from both the standard Python distribution and S60 mobile-specific APIs, not all Python modules are distributed and the mobile APIs are not as comprehensive as those available to the Symbian C++ program.

For example, Python supports some S60 UI widgets but lacks others, which can sometimes make it difficult to implement applications that look and feel similar to native apps.

To help with this, PySymbian can be enhanced through extensions written in Symbian C++ and is constantly being improved by Nokia (and the PySymbian community). Extensions can be downloaded from the various websites of the developers who contribute them.

PySymbian SDKs and Tools

The PySymbian distribution is made up of two components: the runtime, which provides a virtual machine that manages the execution of Python programs, and the script shell, which is used to run scripts.

Currently there are two versions of PySymbian:

  • PySymbian 2.0.0 (latest stable release) available at Maemo Garage - supports S60 3rd Edition and later releases.
    • Recommended for Symbian^1/S60 3nd Edition devices and later
    • Based on Python 2.5.1
  • PySymbian 1.4.5 (stable release) available at sourceforge.net/projects/pys60 - supports S60 2nd Edition and later releases.
    • Recommended for S60 2nd Edition devices
    • Based on Python 2.2.2

PySymbian versions up to and including 1.4.5 are based on Python 2.2.2, while versions starting from 1.9.0 are based on Python 2.5.1. The Python 3.0 port to S60 is not yet road mapped.

The PySymbian 2.0.0 release is recommended for supported devices because it is based on a more modern version of the core, and because it supports many features that are not present on 1.4.5. As suggested in the release announcement, PySymbian v2.0.0 source will be made available soon in Symbian Foundation, so that users can contribute easily and actively to the growth of PySymbian.

The following tables lists the general form of the files available for download at both the above portals and explains what they are for:

Table 1 PySymbian 2.0.0 files
File name Description
PythonForS60_2.0.0_Setup.exe Installation package for Windows. This installs the Application Packager, the full reference documentation for PySymbian and generic Python in HTML format, and a folder containing the SIS files for the PySymbian runtime (Python_2.0.0.sis), script shell (PythonScriptShell_2.0.0_3_X) and dependencies.

Notes:

  • The Application Packager is a Python application; you will need Python 2.5.4 installed to run this on Windows.
PythonForS60_2.0.0.tar.gz For non-Windows users, an archive PythonForS60_2.0.0.tar.gz is available
Python_2.0.0_SDK_3rdEdFPX.zip The PySymbian SDK

For developing on the S60 emulators

Several versions exist, compiled for each supported version of S60

release_notes_2.0.0.txt PySymbian release notes

Table 2 PySymbian 1.4.5 files
File name Description
PythonForS60_1_4_5_XEdFPY.sis The Python runtime

Several versions exist, compiled for each supported version of S60

PythonScriptShell_1_4_5_XEdFPY.sis The Python script shell

Several versions exist, compiled for each supported version of S60

PythonForS60_1_4_5_doc.pdf The relevant PySymbian library reference and API docs (applies to all)
PythonForS60_1_4_5_SDK_XEdFPY.zip The PySymbian SDK

For developing on the S60 emulators

Several versions exist, compiled for each supported version of S60

PythonScriptShell_1_4_5_3rdEd_unsigned_testrange.sis The unsigned version of the script shell
release_notes_1_4_5.txt PySymbian release notes

If you wish to test PySymbian scripts on a Windows PC, you will require an S60 SDK for C++ application development. The SDK you choose should match the S60 version of the target device. A list of S60 devices is available here. An S60 3rd Edition Feature Pack 2 SDK was used for the purposes of this article.

Support for PySymbian

PySymbian extensions and Other Technologies

The following table lists and describes the modules specific to PySymbian. One should note that these modules will not be available in standard Python for PC.

Table 3 PySymbian modules
Module Description
appuifw User interface elements
audio Audio playing and recording
calendar Calendar services
camera Photo and video capturing
contacts Accessing contact information databases
e32 Symbian OS-related utilities
e32db Relational database manipulation
glcanvas UI control for displaying OpenGL ES graphics
gles Python bindings to OpenGL ES
globalui Interface to the S60 global UI notifiers
graphics Image manipulation
inbox Access to inbox, outbox, sent and drafts folders
keycapture Global capturing of key events
location Retrieve location information
logs Generic access to the phone’s log
messaging Messaging services
positioning Retrieve information about the phone’s position using GPS
sensor Access to the device’s physical sensors
socket Bluetooth and other connectivity services
sysinfo Retrieve information about the system
telephone Telephony services
topwindow Creating windows that are shown on top of other applications
scriptext Platform Service API Usage from Python runtime

Pure Python modules (ones that don’t depend on C/C++ extensions) can be ported across different versions of PySymbian. If a module does not rely on a feature or other module that is not available in the target version, the .py or .pyc can be easily copied and used with that version (taking care to ensure that it works with the same version of Python as used by PySymbian).

Python on Symbian extensions can be written in Symbian C++ in order to enhance their functionality. An aggregated list of PySymbian extensions is available at the Nokia Developer Wiki. A tutorial on how to make such extensions is available at Archived:Creating PySymbian 2.0 Extensions (Easy Approach).

Python can also be combined with Flash Lite with the help of the Flyer framework.

PySymbian Resources

PySymbian v1.4.5 Reference Documentation:

PySymbian v2.0.0 Reference Documentation

  • Online version of documentation
  • PythonForS60_2.0.0_Setup.exe (from the maemo garage) contains both generic and PySymbian documentation in HTML format
  • PySymbian documentation is also available in a pdf format (PySymbian_2_0_documentation.pdf).
  • Python 2.5.1 Reference (generic python)

The foremost sources of information about PySymbian are

There are also numerous websites that can prove to be invaluable when learning PySymbian. We recommend the following:

Sample Applications

Numerous outstanding PySymbian applications and games demonstrate what can be done using this powerful language. Some of them are featured below. A concrete list of more PySymbian applications can be found at Nokia Developer Wiki.

  • PyCalc – a utility that demonstrates how to link several scripts and make use of other resources, such as images
  • ShakerRacer – allows you to control a toy racing car with your phone through Bluetooth
  • Location Scheduler – trigger alarms or reminders according to location
  • Tracker – an advanced application that makes use of GPS and maps
  • Unity – an excellent example of the potential PySymbian has for game development
  • Sensor Sample - demonstrates how to use the built-in Sensor API in Python applications
  • Scribble - Paint like application demonstating use of touch support (compatible with PySymbian 1.9.5 and an S60 5th Edition device/SDK)
  • GTranslate - Python application that uses Google translator API to translate English to other languages


Licence icon cc-by-sa 3.0-88x31.png© 2010 Symbian Foundation Limited. This document is licensed under the Creative Commons Attribution-Share Alike 2.0 license. See http://creativecommons.org/licenses/by-sa/2.0/legalcode for the full terms of the license.
Note that this content was originally hosted on the Symbian Foundation developer wiki.

This page was last modified on 8 May 2013, at 06:35.
69 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×