×
Namespaces

Variants
Actions

Archived:How to change screen size 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 N95, Nokia E90, Nokia N82, Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 1st Edition, S60 2nd Edition, S60 3rd Edition, S60 5th Edition
Article
Keywords: appuifw
Created: cyke64 (15 Mar 2007)
Last edited: hamishwillee (31 May 2013)

Contents

Overview

This article shows how to change an application's screen size in PySymbian (Python). The sample code supports any screen size and screen rotation during application runtime.

Preconditions

An application's body uses a normal screen area by default. The currently used area can be retrieved and set by using the screen attribute of the application instance.

The possible screen modes are:

  • 'normal' - title pane and softkeys area are visible (default)
  • 'large' - only softkeys area is visible
  • 'full' - the application's body takes up the entire screen; on S60 5th Edition it has the same effect as 'large', meaning the softkeys area is still visible
  • 'full_max' - introduced in PySymbian 1.9.4; on S60 3rd Edition it has the same effect as 'full' and on S60 5th Edition the application's body takes up the entire screen including the softkeys area

Source code

import e32, appuifw, graphics
 
 
#Global variables to control application execution
app_lock = e32.Ao_lock()
my_timer = e32.Ao_timer()
 
#Global variables for application UI
canvas = None
img = None
 
def cb_quit():
'''Callback for exit, do clean-up'''
my_timer.cancel()
app_lock.signal()
 
def cb_handle_redraw(dummy = (0, 0, 0, 0)):
'''Overwrite default screen redraw event handler'''
#This might be called automatically before img is created
if img:
canvas.blit(img)
 
def cb_handle_resize(dummy=(0, 0, 0, 0)):
'''Overwrite default screen resize event handler'''
global img
#This might be called automatically before canvas is created
if canvas:
#Create a coloured full-screen image
img = graphics.Image.new(canvas.size)
img.clear(0x33CC00)
 
#Initialize application UI
appuifw.app.screen = 'full'
canvas = appuifw.Canvas(resize_callback = cb_handle_resize,
redraw_callback = cb_handle_redraw)
appuifw.app.body = canvas
appuifw.app.exit_key_handler = cb_quit
 
#Initialize application
cb_handle_resize()
 
#Show the 3 possible layouts with a 3 second pause between them
try:
# full_max only in PySymbian 1.9.4, removed after that
appuifw.app.screen = 'full_max'
cb_handle_redraw()
my_timer.after(3)
except:
appuifw.app.screen = 'full'
cb_handle_redraw()
my_timer.after(3)
 
appuifw.app.screen = 'large'
cb_handle_redraw()
my_timer.after(3)
 
appuifw.app.screen = 'normal'
cb_handle_redraw()
 
#Wait for the user to request the exit
app_lock.wait()

Postconditions

The three possible layouts are examplified.

Full screen
Large screen
Normal screen
This page was last modified on 31 May 2013, at 04:03.
59 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.

×