×
Namespaces

Variants
Actions

Archived:Scrolling image in PySymbian

From Nokia Developer 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
Tested with
Devices(s): Nokia N96, Nokia N95-8GB
Compatibility
Platform(s): S60 2nd Ed,S60 3rd Ed
Article
Keywords: Graphics, Canvas
Created: ck.umraliya (07 Jan 2009)
Last edited: hamishwillee (31 May 2013)

Overview

As there exists no standard method to scroll the over sized image on the canvas in PySymbian, Here is the simple way to do so. The following code shows how we can scroll the over sized image without using any extensions.

Script

## Import the needed modules
import appuifw
import e32
from key_codes import *
from graphics import *
global y
 
## Global variables
x=0
y=0
 
## Quit function
def quit():
app_lock.signal()
 
## The function which allow to scroll image.
def scroll(image_obj):
global y
 
# Load the image in to a new image object
img_obj=Image.open(image_obj)
limith,limitv = img_obj.size
 
## Define function that will be used to change the coordinates of the image
def move(b,index):
global y
 
if index == -1:
if y<-(limitv-canvas.size[1]):
y-=b
else:
y+=b
 
if index == 1:
if y<0:
y+=b
else:
y-=b
dis(x,y)
 
def move1(b1,index1):
global x
 
if index1 == -1:
if x<-(limith-canvas.size[0]):
x-=b1
else:
x+=b1
 
if index1 == 1:
if x<0:
x+=b1
else:
x-=b1
dis(x,y)
 
def dis(v1,v2):
display.clear(0xffffff)
## Blit (Draw) the image in the right place
display.blit(img_obj,target=(v1,v2,img_obj.size[0],y+img_obj.size[1]))
canvas.blit(display)
 
## Create the canvas
canvas=appuifw.Canvas(event_callback=None, redraw_callback=None)
## Define the keys
canvas.bind(EKeyUpArrow,lambda:move(8,1))
canvas.bind(EKeyDownArrow,lambda:move(-8,-1))
canvas.bind(EKeyLeftArrow,lambda:move1(8,1))
canvas.bind(EKeyRightArrow,lambda:move1(-8,-1))
 
## Setting canvas as application body
appuifw.app.body=canvas
canvas.blit(img_obj)
display=Image.new(canvas.size)
 
## Pasing the image as argument to scroll function
scroll('e:\\Images\\photo.jpg')
 
## Exit key handler
appuifw.app.exit_key_handler=quit
app_lock=e32.Ao_lock()
app_lock.wait()

Post conditions

Scroll1.jpg Scroll2.jpg Scroll3.jpg

This page was last modified on 31 May 2013, at 01:05.
30 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×