OSCON2009 Python On Symbian
OSCON2009 Python On Symbian
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
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:
import appuifw
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()
appuifw.app.exit_key_handler=quit
lastNumber=None
appLock.wait()
• Allows
you
to
run/restart
Python
and
manipulate
scripts
quickly