===================================== Python in Your Pocket: Python for S60 ===================================== .. include:: .. footer:: PyCon 2006 -24 Feb 2006 .. class:: center :big:`Matt Croydon` Introduction ============ * What is `S60`_? .. class:: handout S60, formerly known as Series 60, is a smartphone platform built on top of Symbian OS. * Why Python on S60? .. class:: handout Python allows developers to write useful applications with very few lines of code. Many standard libraries and APIs are available and virtually any C++ API can be wrapped in a Python extension. Because of this Python allows deeper access to phone features with less overhead than alternatives like J2ME or Symbian C++. * PyS60 overview * based on Python 2.2.2 * Apache 2.0 license .. _S60: http://www.s60.com/ Getting Started =============== * http://sourceforge.net/projects/pys60/ * Phone installer (.sis) * SDK * Source code * Jurgen Scheible's awesome `mobilelin tutorial`__ and `videos`__ __ http://mobilenin.com/pys60/menu.htm __ http://mobilenin.com/ * Steve Litchfield's `tutorial`__ __ http://www.allaboutsymbian.com/features/item/Nokia_Pythons_Flying_Circus.php .. class:: handout Check the `technical device specifications`__ for the correct version to download for your phone. __ http://www.forum.nokia.com/main/0,,150,00.html?matrixType=s60 appuifw Examples ================ Hello World:: import appuifw appuifw.note(u"Hello", 'info') Input (simple popup):: name = appuifw.query(u'Enter your name', 'text') PyS60 Advantages ================ * easy to write * Native widgets * Rapid application development * wxPython-based compatability library * remote bluetooth console * easy to test on an actual device Libraries ========= The entire Python Standard Library is not distributed with PyS60 Some highlights:: anydbm, math, md5, re, urllib, zlib Many other pure-python libraries "just work" by copying the pure python libs (and any dependencies) from the python 2.2.2 source. Some Available APIs =================== * sysinfo: access information about the device (battery levels, memory information, etc.):: battery(), imei(), total.rom() * camera: modify camera settings and take pictures:: image = camera.take.photo() * graphics: create games and custom UIs * audio: play and record audio More Available APIs =================== * telephone: send an SMS:: telephone.dial('411') * inbox: manipulate messages in your inbox * location: retrieve information about cel towers * contacts: access and change Calendar API ============ Add, delete, modify:: now = time.time() cal = calendar.open() a = cal.add_appointment() a.content = 'urgent meeting' a.set_time(now, now) # start and end time a.commit() .. class:: handout From `Series 60 snippets`__ __ http://www.bigbold.com/snippets/posts/show/402 Third Party APIs ================ * `PDIS`_ (Personal Distributed Information Store) * Jabber client/library, expat, xpath, iCal, others .. _PDIS: http://pdis.hiit.fi/pdis/download/ * Nick Burch: `webbrowser.py`__ __ http://gagravarr.org/code/webbrowser.py * Symbian C++ extensions .. class:: handout PDIS also has a S60 compatability library that uses wxPython to emulate appuifw. This library makes initial application development very easy because apps can be roughed out on a desktop machine without having to code, send to device, load, test. .. class:: handout Nick also has some awesome Python for Series 60 apps and hacks including `NMEA Info`__ and `log location`__. __ http://gagravarr.livejournal.com/104793.html __ http://gagravarr.livejournal.com/106379.html Pure Python Libraries ===================== Many pure python libraries "just work" with either the core PyS60 distribution or with the addition of required libraries from the Python 2.2.2 source. * `BeautifulSoup`_: mobile screen scraping * Cryptography: `Rijndael`_ `Blowfish`_ `3DES`_ .. _BeautifulSoup: http://crummy.com/software/BeautifulSoup/ .. _Rijndael: http://www.postneo.com/2005/03/31/more-python-for-series-60-crypto-rijndael .. _Blowfish: http://www.postneo.com/2005/03/28/blowfish-in-your-pocket .. _3DES: http://www.postneo.com/2005/03/28/python-for-series-60-crypto-des PyS60 Applications (1) ====================== `nmea_info`__ - `traffic cam`__ - `quotegrab`__ .. image:: images/nmea_info.jpg .. image:: images/traffic_cam1.jpg .. image:: images/quotegrab3.jpg __ http://gagravarr.livejournal.com/104793.html __ http://crschmidt.net/symbian/traffic/ __ http://www.postneo.com/2005/04/09/python-for-series-60-app-quotegrab PyS60 Applications (2) ====================== `dict2go`__ - `musician`__ - `dashboard`__ .. image:: images/dict2go2.jpg .. image:: images/musician1.jpg .. image:: images/dashboard.gif __ http://www.postneo.com/2005/04/05/useful-python-for-series-60-app-dict2go __ http://3lib.ukonline.co.uk/musician.htm __ http://pymbian.sourceforge.net/misc/dashboard/ Distributing Applications ========================= * When you send a .py file to the phone, it prompts you to install as a script or a library * py2sis allows you to package your app and libraries in to an easy to install .sis file .. class:: center .. container:: install .. image:: images/install.jpg What a Difference a Year Makes ============================== Since PyCon last year: * PyS60 has been open-sourced * several new API hooks have been added * apps are maturing PyS60 Community =============== * `Forum Nokia message board`__ * `Unofficial wiki`__ * `Symbian Hacks`__ mailing list * `PyS60 Snippets`__ * `Sourceforge summary`__ __ http://discussion.forum.nokia.com/forum/forumdisplay.php?f=102 __ http://postneo.com/postwiki/moin.cgi/PythonForSeries60 __ http://crschmidt.net/mailman/listinfo/symbian-hacks __ http://www.bigbold.com/snippets/tag/series60 __ http://sourceforge.net/projects/pys60/ What Comes Next? ================ * `mod_python + S60`__ = Crazy Delicious * What about Symbian OS 9? __ http://research.nokia.com/research/projects/mobile-web-server/index.html .. class:: handout Note that apache + mod_python is an internal Nokia research product and is not available to the general public. Questions - Slides ================== .. class:: huge center Questions? .. class:: center Slides are available at http://postneo.com/talks/pycon2006/ ReST source: http://postneo.com/talks/pycon2006/presentation.txt