3.1. Using Modules

The native UI elements that PyS60 offers are accessible through a module called appuifw (which stands for application user interface framework).

It is an interface to the S60 UI application framework that takes care of all UI functionalities on the S60 platform. But before we go on, let's learn what a 'module' is in Python, in the language lesson.

Python Language Lesson: module

A module is a file that contains a collection of related functions and data grouped together. PyS60 comes with a rich set of modules, for example messaging to handle SMS functionalities, camera for taking photos, and appuifw, which provides ready-to-use UI elements. The modules' contents are described in detail in the Python Library Reference and Python for S60 API documentation. We also learn about many of them in this book.

To use a module in your code, it must be imported at the beginning of the script, for example:

import appuifw

To address a function contained in a module, we first write the module name, a dot and then the function name:

appuifw.query (label, type)

Here, appuifw is the module name and query is the function we want to use.

You may import many modules using a single import statement:

import appuifw, e32

This imports two modules: appuifw and e32.

As you might remember from our Example 1 (Chapter 2), we used the functions query() and note(), which belong to the appuifw module. These functions generate UI elements, dialogs, that are displayed on the screen when the ...

Get Mobile Python: Rapid Prototyping of Applications on the Mobile Platform now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.