×
Namespaces

Variants
Actions
Revision as of 19:50, 25 April 2009 by bogdan.galiceanu (Talk | contribs)

Archived:How to change screen size in PySymbian

From Nokia Developer Wiki
Jump to: navigation, search
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: (15 Mar 2007)
Last edited: bogdan.galiceanu (25 Apr 2009)

Contents

Overview

This article shows how to change an application's screen size in PyS60 (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 PyS60 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:
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
64 page views in the last 30 days.