×
Namespaces

Variants
Actions

Archived:Progress bar on S60 5th Edition using 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
Compatibility
Platform(s):
S60 5th Edition
Article
Created: croozeus (10 Oct 2008)
Last edited: hamishwillee (31 May 2013)

Contents

Introduction

Now that we can use PySymbian on the S60 5th Edition SDK (link), here is a small code snippet which creates a progress bar in Python. A progress bar is a component in a graphical user interface used to convey the progress of a task, such as a download or file transfer. This code can also be used with earlier S60 editions.

Code Snippet

In the below code, the progress bar advances 10% at every second. However, it can be adapted to various events such as download time or any other timed process.

#import modules
import appuifw, e32, graphics, sysinfo
 
 
app_lock=e32.Ao_lock()
# defining the exit handler
def quit():
app_lock.signal()
appuifw.app.exit_key_handler=quit
 
#setting application title
appuifw.app.title=u"Progress Bar"
 
#setting the screen size
appuifw.app.screen="normal"
 
#define image resolution
img=graphics.Image.new(sysinfo.display_pixels())
img.rectangle(((20,sysinfo.display_pixels()[1]/2-20),(sysinfo.display_pixels()[0]-20,sysinfo.display_pixels()
 
[1]/2+20)), outline=(0,0,0))
 
def hr(rect):canvas.blit(img)
canvas=appuifw.Canvas(redraw_callback=hr)
appuifw.app.body=canvas
 
p=0
 
#Increment the progress bar by 10% every second.
for i in range(10):
img.rectangle(((p,sysinfo.display_pixels()[1]/2-20),(p+(sysinfo.display_pixels()[0]-40)/10,sysinfo.display_pixels()[1]/2+20)), fill=0)
canvas=appuifw.Canvas(redraw_callback=hr)
p+=(sysinfo.display_pixels()[0]-40)/10
print i
e32.ao_sleep(1)
 
app_lock = e32.Ao_lock()
app_lock.wait()


Post Conditions

Progressbar 5th 1.jpg Progressbar 5th 2.jpg

  1. Progress bar with 40% progress
  2. Progress bar with 100% progress

See Also

C.B.S MESSAGE

This page was last modified on 31 May 2013, at 04:10.
92 page views in the last 30 days.