0% found this document useful (0 votes)
219 views

OSCON2009 Python On Symbian

Presentation about developing Python on Symbian given at OSCON 2009 by Herb Jellinek. Content is copyright Herb Jellinek, licensed under Creative Commons BY-SA

Uploaded by

Symbian
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
219 views

OSCON2009 Python On Symbian

Presentation about developing Python on Symbian given at OSCON 2009 by Herb Jellinek. Content is copyright Herb Jellinek, licensed under Creative Commons BY-SA

Uploaded by

Symbian
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

Python
for
S60


Easy,
rapid
prototyping
of
mobile

applica:ons
on
the
S60
pla;orm


Herb
Jellinek,
Supported
So@ware
LLC

jellinek
at
newscenter
dot
com


July
2009
 Copyright
©
2009,
Herb
Jellinek
 1

Python?

•  General‐purpose
object‐oriented

programming
language

•  Allows
edit‐compile‐test
as
well
as
completely

interac:ve
execu:on

•  Language,
libraries,
and
paOerns
of
use

encourage
readability
and
produc:vity

•  Open
source
project
with
a
large
user

community


July
2009
 Copyright
©
2009,
Herb
Jellinek
 2

What
is
Python
for
S60?

•  Nokia’s
port
of
the
Python
run:me
to
the
S60

smartphone
pla;orm

•  Python
core
language

•  Rich
set
of
capabili:es

–  Large
set
of
standard
Python
libraries,
plus

–  Mobile‐specific
API

•  AKA
PyS60


July
2009
 Copyright
©
2009,
Herb
Jellinek
 3

Why
PyS60?

•  Easy
to
get
started

•  Can
test
applica:on
ideas
and
pla;orm
features

•  Provides
access
to
many
pla;orm
features
out
of
the
box

–  Network,
file
system,
messaging,
contacts
database

–  Bluetooth,
camera,
loca:on/GPS,
sensor
framework

–  Etc.

•  More
func:onality
than
Java
and
Flash
Lite
run:mes
(no
“sandbox”)

•  Can
extend
with
na:ve
modules
for
addi:onal
capabili:es

•  Quick
edit/test/edit
cycle
on
real
device
or
emulator

•  Interac:ve
Bluetooth
console

•  Runs
on
a
large
number
of
devices

•  Open
source
project
with
ac:ve
developer
community

•  Tools
are
free
and
run
on
most
major
OSes


•  Great
for
demonstra:ng
product
ideas
to
senior
management!


July
2009
 Copyright
©
2009,
Herb
Jellinek
 4

Why
not
PyS60?

•  Not
supported
on
other
mobile
device

pla;orms

•  More
overhead,
lower
performance
than

na:ve
Symbian
C++

•  Must
install
Python
on
the
phone
manually
–
a

slightly
cumbersome
process


July
2009
 Copyright
©
2009,
Herb
Jellinek
 5

Geing
Started

•  Choose
a
pla;orm

–  PyS60
1.4.5
(stable
release,
Python
2.2.2
base)
or

–  PyS60
1.9.6
(beta
release,
Python
2.5.1
base)

•  Choice
depends
on
your
technical

requirements
and/or
taste
for
adventure


July
2009
 Copyright
©
2009,
Herb
Jellinek
 6

Geing
Started

•  (assume
PyS60
1.4.5
and
S60
3rd
Edi:on
FP1
device)

•  Download
from
hOp://sourceforge.net/projects/pys60/:

Component
 Name
 Example


Python
run:me
 PythonForS60_1_4_5_xE PythonForS60_1_4_5_3rdEd.sis



dFPy.sis

Python
script
shell
 PythonScriptShell_1_4_5 PythonScriptShell_1_4_5_3rdEd.
_xEdFPy.sis
 sis

Documenta:on
 PythonForS60_1_4_5_do
c.pdf

Release
notes
 release_notes_1_4_5.txt


July
2009
 Copyright
©
2009,
Herb
Jellinek
 7

Geing
Started

•  Transfer
run:me
and
script
shell
to
phone

–  PythonForS60_1_4_5_3rdEd.sis

–  PythonScriptShell_1_4_5_3rdEd.sis

–  When
Installer
asks
to
install,
say
yes!

•  Order
maOers;
install
run:me
first

•  Create
E:\Python
directory
on
phone
for

scripts

•  Can
also
run
on
S60
Emulator

July
2009
 Copyright
©
2009,
Herb
Jellinek
 8

Examples

•  Hello,
World
–
Console

•  Hello,
World
–
from
script
menu

•  Hello,
World
–
appuifw

•  Text
Messaging

•  Telephony

•  GPS


July
2009
 Copyright
©
2009,
Herb
Jellinek
 9

Hello,
World

•  Open
Bluetooth
console
and
type
this:


print u”Hello, world!”

July
2009
 Copyright
©
2009,
Herb
Jellinek
 10



Hello,
World


July
2009
 Copyright
©
2009,
Herb
Jellinek
 11



Hello,
World

•  Create
helloworld.py
and
copy
to
E:\Python:


print u“Hello, world!”

July
2009
 Copyright
©
2009,
Herb
Jellinek
 12



Run
Your
Script


July
2009
 Copyright
©
2009,
Herb
Jellinek
 13



Hello,
World
á
la
PyS60

•  Use
the
appuifw
module
to
set
the
:tle
and

pop
up
a
note


import appuifw

appuifw.app.title = u"The Universal Program"


appuifw.note(u"Hello, world!")

July
2009
 Copyright
©
2009,
Herb
Jellinek
 14



Hello,
World
á
la
PyS60


July
2009
 Copyright
©
2009,
Herb
Jellinek
 15



A
Bit
More
UI

import appuifw, e32

def quit():
appLock.signal()

textObj = appuifw.Text()
textObj.font = "title"
textObj.set(u”Hello, World!”)

appLock = e32.Ao_lock()

appuifw.app.exit_key_handler = quit
appuifw.app.body = textObj

appLock.wait()

July
2009
 Copyright
©
2009,
Herb
Jellinek
 16



A
Bit
More
UI


July
2009
 Copyright
©
2009,
Herb
Jellinek
 17



Using
Pla;orm
API’s:
Text
Messaging

•  inbox
module
accesses
messages
in
device

inbox

>>> import inbox
>>> inb = inbox.Inbox()
>>> messages = inb.sms_messages()
>>> for m in messages:
... print inb.address(m)
...
Wessling Susana
AT&T email gateway
Wessling Susana
Wessling Susana
AT&T email gateway
AT&T email gateway
18314307294
July
2009

>>> Copyright
©
2009,
Herb
Jellinek
 18

Using
Pla;orm
API’s:
Telephony

import appuifw, telephone, e32, audio
appLock=e32.Ao_lock()
def quit():
appLock.signal()

appuifw.app.exit_key_handler=quit
lastNumber=None

def callState((state, number)):


global lastNumber
if (state == telephone.EStatusRinging):
lastNumber = number
if (state == telephone.EStatusDisconnecting):
audio.say(u”Call was from %s” % lastNumber)

# register the callback


telephone.call_state(callState)

appLock.wait()

July
2009
 Copyright
©
2009,
Herb
Jellinek
 19



Using
Pla;orm
API’s:
GPS


Source code and details forthcoming at


developer.symbian.org/wiki/index.php?title=Location_Based_Services

July
2009
 Copyright
©
2009,
Herb
Jellinek
 20



Time‐saving
Tips

•  Add
the
Python
script
shell
and
File
Manager

to
the
Ac:ve
Standby
Apps
(name
varies)


•  Allows
you
to
run/restart
Python
and

manipulate
scripts
quickly


July
2009
 Copyright
©
2009,
Herb
Jellinek
 21



Time‐saving
Tips

•  Use
Nokia
PC
Suite
or
Bluetooth
file
browser

on
dev
computer


July
2009
 Copyright
©
2009,
Herb
Jellinek
 22



Time‐saving
Tips

•  Consider
using
a
source
code
control
system

for
those
“what
was
I
thinking?”
moments


July
2009
 Copyright
©
2009,
Herb
Jellinek
 23



Conclusion

•  Python
for
S60
(PyS60)

•  Shallow
learning
curve

•  Quick,
easy
experimenta:on
and
development

•  Advantages
and
disadvantages

•  Comparison
with
other
S60
pla;orms

•  Examples

•  So
much
more
to
explore

–  Modules,
libraries,
packaging,
best
prac:ces,
code

signing,
…


July
2009
 Copyright
©
2009,
Herb
Jellinek
 24



Thank
You

•  Ques:ons?


July
2009
 Copyright
©
2009,
Herb
Jellinek
 25



Contact

•  Herb
Jellinek,
Supported
So@ware,
LLC

•  jellinek
at
newscenter
dot
com


July
2009
 Copyright
©
2009,
Herb
Jellinek
 26


You might also like