Python Quick Start
From Symbian Developer Community
This Quick Start document provides information on how to begin developing Python applications for the Symbian platform. At the end of the tutorial you will have installed Python (PyS60 v2.0.0 release) on your phone or Emulator, written a basic helloworld application and run it on the phone both from the interactive shell script and as a stand-alone application.
If you are completely new to Python we recommend you start your development on the desktop - by taking the short course Dive Into Python or working through the tutorial: Python Programming for the Non Programmer.
| Comes with Code: | File:PythonHelloWorld.zip |
Contents |
Setting Up Your Development Environment
Python applications ("scripts") are simply text files containing code written in the Python programming language and named with the file extension ".py". The scripts can be written in any text editor and can be run either from within the Python Interactive Shell application on a device or the emulator, or as standalone applications on your mobile device.
Getting PyS60
The Python files are stored on the Maemo Garage - descriptions are provided for all files in the Python Technical Overview.
Windows developers need the following files for this tutorial:
- PythonForS60_2.0.0_Setup.exe - Windows Installer
- Python_2.0.0_SDK_3rdEdFP2.zip - Patch over SDK to support Python development
Mac and Linux developers need the following file instead:
- PythonForS60_2.0.0.tar.gz - Mac/Linux archive
Setting up your Computer
The development environment consists of the Python reference documentation, the Application packager for making your scripts into stand-alone applications and the phone SIS files. Run the following setup file to install on windows, or unzip the archive to install on Mac/Linux:
- (Windows) PythonForS60_2.0.0_Setup.exe
- (Mac/Linux) PythonForS60_2.0.0.tar.gz
On Windows the tools/documentation are accessible from a start menu option: Start | Programs | PythonForS60 2.0.0. Mac/Linux users will need to execute files directly (ie run the Application Packager by executing ensymble_gui.py).
You will need to install the Python for your desktop in order to use the Application Packager. This can be obtained from here: Python 2.5.4.
A text editor is used for writing scripts. You can use any one you like, including Windows Notepad. We recommend a syntax-aware editor like Notepad ++.
| Note While you can write code in the classic Python python.org/idle IDLE IDE, it is not possible to run code that depends on PyS60-specific libraries from this or other IDEs. They must be run in the S60 emulator or on the target device. |
Installing Python on your Phone
The easiest way to test your Python application is to run it on a real phone. PyS60 v2.0.0 is compatible with any Symbian device (based on Symbian^1 or earlier S60 3rd Edition devices). If you don't have a compatible phone, don't worry - the following section explains how you can run your scripts on the Windows-hosted Symbian platform emulator.
The SIS you need are available in the directory \PythonForS60\PyS60Dependencies\ of your Python installation (Windows users can open the directory from the start menu).
Using your PC Suite software, install the following files to your Symbian device (based on Symbian^1 or S60 3rd Edition):
- Python_2.0.0.sis - The PyS60 runtime
- PythonScriptShell_2.0.0_3_2.sis - Python Interactive Shell application for Symbian^1 and S60 3rd Edition FP2 (and later). PythonScriptShell_2.0.0_3_0.sis should be used for earlier S60 3rd Edition devices.
You can verify the installation by launching the Python icon from the device Installations folder. If you do menu Options | Run Script, you can select some pre installed scripts to demonstrate the power of python! The icon and list of applications are shown below:
Installing Python on your Symbian Emulator
Install the following files (in order):
- S60_5th_Edition_SDK_v1_0_en.zip (Symbian^1 Application Development Kit)
- Python_2.0.0_SDK_3rdEdFP2.zip (Python patch)
Note that you'll first need to unzip the SDK to a temporary directory, and then run setup.exe. The installation will suggest you install Perl - this is only necessary for C++ developers; Python developers may ignore the warning. The patch will then need to be unzipped over the SDK, so that it overwrites the SDK's \epoc32\ directory. Accept all prompts during unzipping to allow this to happen.
On first use, the SDK may prompt you to register it. The process is straight forward, but you will need to sign up with Forum Nokia if you haven't already.
You can launch the Emulator by clicking on the file [SDK]/epoc32/release/winscw/udeb/epoc.exe. You then navigate to the Python icon in the Emulator in the same way as you did on the device.
If Python shows an error message stating that the Python Runtime or PIPS Library are not installed you will need to install the Open C/C++ Plugin.
Your first script
The very simple script below asks the user for their name, then displays a dialog with the text: "Hello Name, welcome to Python World."
# import the app user interface framework module
import appuifw
# create a single-field dialog (text input field): appuifw.query(label, type)
data = appuifw.query(u"Type your name", "text")
# create an information note: appuifw.note(label, type)
appuifw.note(u"Hello "+str(data)+", welcome to Python World", "info")
Copy this text into your preferred text editor and then save the file as Helloworld.py (the ".py" extension is used for uncompiled python scripts).
If you're using the interactive shell for testing, you need to copy the file to \Data\Python\ on any drive. For the device you can copy the file directly into the correct folder using PC Suite, or send it as a message with Bluetooth and then move it to the correct folder, using a file manager application (YBrowser - recommended). If you're using the emulator you can copy it direct into the appropriate folder - [SDK]/epoc32/winscw/c/data/python.
You can then test your script in the same way you verified the Python installation - by launching the "Python2.0.0" icon for the interactive shell, then doing "Options | Run Script" and selecting it from the list.
That's it. You now have Python on your device and/or your Emulator, and know how to launch scripts. The next section shows how you can package your script as an application.
Making a Standalone Application
Scripts are ideal for testing because they can be quickly and easily modified. However, an application should be distributed in the form of an installable SIS file. This applies even more when the application has external resource files that have to be distributed with it.
For PyS60 2.0.0 you can use the Application Packager to create your Symbian installation (.sis) file. Note that the Application Packager is itself a Python application, so you will first need to install Python on your Windows PC from here.
Once Python is installed, you can launch the Packager by double clicking the icon in your Python for S60 directory: \PythonForS60\ensymble_gui.py or by selecting the Windows Start menu option: Start | PythonForS60 2.0.0 | PyS60 Application Packager.
The application initially opens in a minimal view (Figure 3), in which you can specify either a single file or a folder that you want to package as an application, and whether you want the package to be created if the packager can't find a dependency. Brows to the Helloworld.py script we created earlier, then Press Create to make the SIS file.
The Helloworld_v1_0_0.sis installation file is created in the same directory as your script file. The file is created with a version number of 1.0.0, a UID in the development range, and will be self-signed. This is suitable for testing, but if you wanted to distribute the file you would need to make some changes (there are detailed instructions on how to do so in the wiki book Python on Symbian).
The packager will then give you the option to install the application or to open the folder in which it is located. If you have PC Suite running you can then install the file directly.
| Note SIS files created with the application packager do not include the Python runtime. When the installed application is launched, Symbian platform devices (including S60 3rd Edition FP2 devices, and later) will automatically detect if the needed version of Python is present on the device, and offer the user the option to download the missing dependencies. On S60 3rd Edition, FP1 (and older) devices the user will need to separately download and install the Python runtime SIS file. |
Summary
This Quick Start tutorial has shown you how to get set up with Python on the Symbian platform, from getting the developer environment through to making standalone applications.
Related Information
There are plenty of public domain resources to help you get started on learning generic Python, and the PyS60 flavour in particular:
- Python in a Nutshell
- Python Technical Overview
- Dive Into Python - Free book on (Generic) Python programming
- Forum Nokia's Python Elearning Module
- Forum Nokia's Official Python Training course with worked examples
- Applications on Croozeus.com blogs
- Croozeus.com Tutorials
- Mobilenin Tutorials.
- Python reference library (including the modules for PyS60) installed as part of your windows setup.
- Python 2.5.1 Reference (generic python)
- Mobile Python - Rapid prototyping of applications on the mobile platform by Jürgen Scheible and Ville Tuulos. Symbian Press provides a sample introductory chapter online and a website with source code for all the examples in the book: www.mobilenin.com/mobilepythonbook/examples.html
Comments
Contents |
Stichbury said...
Hamishwillee said...
Thank you. Done. Also updated to v1.9.7 (just came out) and made less windows-centric
--Hamishwillee 02:18, 10 August 2009 (BST)
Sreenathkg said...
Hi, Need help please.
I am using windows OS in my system and NOKIA 5800 handset. I have installed the apps as specified above.
In system: PythonForS60_1.9.7_Setup Python 3.1
In mobile: PythonScriptShell_1.9.7
In mobile it is working perfectly.
But in my system, I am not able to open Start -> PythonForS60 1.9.7 -> PyS60 Application Packager. I clicked on this. But no windows opened.
I uninstalled python 3.1 from system. And tried to open Application Packager. Then it is throwing error "windows could not find application to open this type of files".
What should I do now? Please help.
Thanks Sreenath
--Sreenathkg 12:13, 20 August 2009 (BST)
Stichbury said...
Hi Sreenathkg
It would probably be better if you posted your question in the discussion forum related to Python development. More people view that and are able to help you. You can find the forum here.
--Stichbury 15:03, 20 August 2009 (BST)
Hamishwillee said...
@Sreenathkg As Jo says, try the forums in future please. I suspect your problem is that the application packager is a Python 2.5.4 applications, which you need installed on your windows PC (installing will automatically set up correct paths). This is covered above
--Hamishwillee 00:52, 21 August 2009 (BST)
Sreenathkg said...
I think as this is beta "Forum is just getting filled"...
--Sreenathkg 22:20, 21 August 2009 (BST)
Stichbury said...
You're right, it is a bit quiet on the forums, but Pankaj (aka "Croozeus") does check them and we're hoping others do too. If you post, you'll be one of the first on the forum, and will be helping us to start the ball rolling. Thanks!
--Stichbury 08:31, 22 August 2009 (BST)
Samaelsamuel said…
the emulator actually asks for perl. might want to mention that..or maybe provide a link to remove the hassles of searching for it. just a suggestion :D
--Samaelsamuel 18:16, 9 February 2010 (UTC)
Hamishwillee said…
@Samaelsamuel Thanks very much. I've added a comment that the perl installation is only relevant to C++ developers here: http://developer.symbian.org/wiki/index.php/Python_Quick_Start#Installing_Python_on_your_Symbian_Emulator
Note that this is a wiki, so you're more than welcome to make this sort of change yourself :-)
--Hamishwillee 23:21, 9 February 2010 (UTC)
Deepakpatil23 said…
Hiii,
I Created a small application in python on my symbian now i create a sis file using standalone application that sis file won't work with windows CE mobile do i need to write a new whole program for same??? or this Python will work on that Win CE mobile and how???
Thanks in advance
--Deepakpatil23 19:48, 17 March 2010 (UTC)
Hamishwillee said…
@Deepakpatil23 Windows CE may or may not support Python, but it doesn't support the same UI framework as Python on Symbian. So yes, you will at least need to re-write the UI parts of your application.
If you want to work cross platform, the best options are web runtime widgets and Qt.
--Hamishwillee 23:27, 17 March 2010 (UTC)
Sign in to comment…




This page is really nice - the adjustment to separate out the Getting Started material from the technology background has worked well. Thanks!
However, should it perhaps be "Comes with Code" as well? Then you can distribute the example script (however simplistic it is). I've done that for the Flash Lite example.
--Stichbury 14:09, 31 July 2009 (BST)