Custom Search

Sunday, January 3, 2010

PyS60 Tutorial - Setting Title

PyS60 Tutorial - Setting Title

1) First PyS60 Application

# Email: sanjufoss@gmail.com

/************ Complete Source Code Start *************/

import appuifw, e32

def quit():

app_lock.signal()

appuifw.app.exit_key_handler=quit

appuifw.app.title=u"MyFirstApplication"

app_lock=e32.Ao_lock()

app_lock.wait()

/************ Complete Source Code end *************/

/*********** Description Start *************/

# Importing Modules

import appuifw, e32

# Define the exit function 'quit'.

def quit():

# Signals the lock object 'app_lock' to release the main thread from waiting state and exit.

app_lock.signal()

# Setting attribute 'exit_key_handler' of 'Application' type instance or object 'app'.

# A callable object(function) 'quit' is called when the user presses the Exit softkey.

# Binding function ‘quit’ with event handler ‘exit_key_handler’.

appuifw.app.exit_key_handler=quit

# Setting attribute 'title' of 'Application' type instance 'app'.

# The title must be in Unicode

appuifw.app.title=u"MyFirstApplication"

# Creating instance 'app_lock' of 'Ao_lock' type.

# Creating lock object 'app_lock'.

app_lock=e32.Ao_lock()

# Signals the lock object 'app_lock' to put main thread in waiting state.

# Calling wait() method of lock object 'app_lock' to put main thread in waiting state.

app_lock.wait()

/*********** Description End *************/

/************ Note Start *************/

The e32 module offers Symbian OS related utilities that are not related to the UI and are

not provided by the standard Python library modules.

Ao_lock() Creates an Ao_lock instance. A Symbian active object based synchronization service.

This can be used in the main thread without blocking the handling of UI events. The application

should not exit while a thread is waiting in Ao_lock. If Ao_lock is called while another wait is in

progress, an AssertionError is raised.

Instances of Ao_lock type have the following methods:

wait()

If the lock has already been signaled, returns immediately. Otherwise blocks in wait for the lock

to be signaled.Only one waiter is allowed, so you should avoid recursive calls to this service.

wait() can only be called in the thread that created the lock object. During the wait,

other Symbian-active objects are being served, so the UI will not freeze. This may result in the

UI callback code being run in the context of the thread that is waiting in Ao_lock. This must be

considered when designing the application logic.

signal()

Signals the lock object .The waiter is released.

/************ Note End *************/

No comments:

Post a Comment