Tuesday, December 8, 2009

Go on with pyS60

I got a very good feedback from my previous post: "How to simulate PyS60 in your PC". As the request of opentechlab readers, I am attempting to write a brief beginner level tutorial on pyS60 emulator.

Once you are successful in installing and setting up the environment (If you didn't set up yet, click here), it is the time to go on.

Start the emulator program from:

Start->All programs -> S60 Developer tools -> 3rd edition FP2 SDK -> v1.1 -> Emulator

You probably need to wait for a couple of seconds to load it if your system is slow. Then a medium sized window with a full fledged mobile phone appears on the screen.

Now you need to open python. Just do as in your mobile phone. it's in Menu -> Installations -> python.

Now it's ready and do what you want.

Hacking python script

Select options -> Run script ->ball.py

You can move the ball anwhere in the screen. It's a physics simulation example in python. You can see the actual python script by opening ball.py file using any editor (notepad is not recommended. programmers notepad is good). The file is stored in :

C:\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\winscw\c\python

Search for the word 'blobsize'. Then you can find a line like:

blobsize = 16

Change the value of blobsize into 25 and save it. Then open ball.py in emulator. Did you notice any change? Similarly you can change acceleration, gravity (what about changing gravity into -0.01 ?) etc.

Developing your own programs

I am just starting with a hello world. Here is the program.

1)Simple hello world

print "Hello World!"

2)Say, hello world

from audio import*

say("Hello World!")

3)graphical hello world!

import appuifw
appuifw.note(u"Hello World!", "info")

It is good practice to make a short cut of python on the mobile desktop by changing options in settings.

No comments: