Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Archived:Getting started with game programming on PySymbian

From Wiki
Jump to: navigation, search

Archived.pngAquivado: Este artigo foi arquivado, pois o conteúdo não é mais considerado relevante para se criar soluções comerciais atuais. Se você achar que este artigo ainda é importante, inclua o template {{ForArchiveReview|escreva a sua justificativa}}.

All PySymbian articles have been archived. PySymbian is no longer maintained by Nokia and is not guaranteed to work on more recent Symbian devices. It is not possible to submit apps to Nokia Store.

Article Metadata
Created: anees042 (21 Oct 2008)
Last edited: hamishwillee (08 May 2013)

This example shows how to do the basic key handling, how to draw graphics to screen,, how to move a graphic with the help of keypad, and how to clear the screen.


# __author__='Fayyaz Ali'
# version = '1.0 beta'
# filename=''
# license='GNU GPL'
# import the required modules
import e32, appuifw, key_codes, graphics
# define the exit function
def quit():app_lock.signal()
# make the screen large'large'
global x,y
x = 110
y = 160
# this method is for handling the redraw event of canvas
def handle_redraw(rect):
# this method is called when the ok button is pressed
def press_select():
# this method is called when the right button is pressed
def press_right():
global x
# this method is called when the left button is pressed
def press_left():
global x
# this method is called when the up button is pressed
def press_up():
global y
# this method is called when the down button is pressed
def press_down():
global y
def update():
# clear img
# open an image"e:\\Images\\area.png")
# resize the image
img2 = img1.resize((20,20))
# copy the img1 to img
img.blit(img2, (0,0), (x, y))
# create an empty image according to the resolution of the phone,320))
# create an object of the Canvas
# bind the canvas with keys, so that it can listen to
# key presses of those keys and do some actions on each key
# we are passing two parameters to the bind method of canvas class.
# The first is the key code to which we want our application to
# listen to events. And the second is handler for the event.
canvas.bind(key_codes.EKeySelect, press_select)
canvas.bind(key_codes.EKeyDownArrow, press_down)
canvas.bind(key_codes.EKeyUpArrow, press_up)
canvas.bind(key_codes.EKeyRightArrow, press_right)
canvas.bind(key_codes.EKeyLeftArrow, press_left)
# set the application body to canvas
This page was last modified on 8 May 2013, at 06:18.
32 page views in the last 30 days.