Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Archived:Basic PySymbian app - series2

From 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
Created: gaba88 (19 Jul 2008)
Last edited: hamishwillee (31 May 2013)



The first article in this series was very important because it focused mainly on how to guide your application by using a proper architecture. In that article there were the basic things to consider when building a PySymbian application.

Now it is time to go more technical and learn about other important fundamentals application development. In PySymbian, a developer should always keep in mind that application s/he is designing should always exit properly when the user wants to do so.

This article will help in understanding this point.

A Simple Application

Consider the code snippet written below:

import appuifw

When someone runs this application on a device, it simply shows a note saying HI. One important thing to notice is that the application displays the note for a few seconds, and then it vanishes automatically without user intervention.

Next Important Step

Now consider another important code snippet below:

import appuifw,e32
def quit():
print u"exit key pressed"
def main():
appuifw.note(u"HI","info") = u"Main"
main() = quit
app_lock = e32.Ao_lock()

In this example, our application has Main as its title and it displays a note. One important thing to notice is that this application does not exit automatically.

This application exits only when the user presses the right soft key (i.e. the exit key).


Some important things about the previous code snippet:

  • we have used two modules: one is the e32 module and the other is the appuifw module.
  • We have used a function named exit_key_handler which is a member of the app object of the appuifw module.
  • Whatever callback function we assign to exit_key_handler is called when the right soft key is pressed.
  • We have used an object from the e32 module, Ao_lock. This object is mainly responsible for creating a lock for the application.
  • The Ao_lock object has two functions named wait and signal.
  • When we call the function wait, a lock is created on the application. The lock is released when the corresponding signal function is called.
  • So we have called the signal function in a callback function quit which the exit_key_handler function calls.
  • This makes our application user-controlled, which means that whenever the user presses the exit button, the application exits.


This is a very important concept one should always keep in mind when designing an application.

Useful links

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