Learn Python
Learn Python
04 July 2007
Nokia
Copyright c 2004-2007 Nokia Corporation. This is Python for S60 version 1.4.0 nal created by Nokia Corporation. Files added by Nokia Corporation are licensed under Apache License Version 2.0. The original software, including modications of Nokia Corporation therein, is licensed under the applicable license(s) for Python 2.2.2, unless specically indicated otherwise in the relevant source code le. See http://www.apache.org/licenses/LICENSE-2.0 and http://www.python.org/2.2.2/license.html
ii
CONTENTS
1 Introduction 1.1 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3 Naming Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 API 2.1 2.2 2.3 Summary Python Standard Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Python for S60 Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Third-Party Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1 1 2 2 3 3 3 4 5 5 5 6 6 6 6 7 7 7
3 Selected Issues on Python Programming for S60 3.1 Concurrency Aspects . . . . . . . . . . . . . . . . 3.2 Running Python for S60 Scripts . . . . . . . . . . 3.3 Standard I/O Streams . . . . . . . . . . . . . . . . 3.4 Usage of Unicode . . . . . . . . . . . . . . . . . . 3.5 Date and Time . . . . . . . . . . . . . . . . . . . . 3.6 Limitations of Thread Support . . . . . . . . . . . 3.7 Scalable User Interface . . . . . . . . . . . . . . . 3.8 Error Handling . . . . . . . . . . . . . . . . . . . . 3.9 Limitations and Areas of Development . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
4 Operating System Services and Information 9 4.1 e32 A Symbian OS related services package . . . . . . . . . . . . . . . . . . . . . . . . 9 4.2 sysinfo Access to system information . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 5 User Interface and Graphics 5.1 appuifw Interface to the S60 GUI framework . . . . . . . . . . . . 5.2 graphics A graphics related services package . . . . . . . . . . . . 5.3 camera Interface for taking photographs . . . . . . . . . . . . . . . 5.4 keycapture Interface for global capturing of key events. . . . . . . 5.5 topwindow Interface for creating windows that are shown on top of 5.6 gles Bindings to OpenGL ES . . . . . . . . . . . . . . . . . . . . . 5.7 glcanvas UI Control for Displaying OpenGL ES Graphics . . . . . 6 Audio and Communication Services 6.1 audio An audio related services package . . . 6.2 telephone Telephone services . . . . . . . . . 6.3 messaging A messaging services package . . 6.4 inbox Interface to device inbox . . . . . . . . 6.5 location GSM location information . . . . . 6.6 position Simplied interface to the Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Acquisition API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . other applications. . . . . . . . . . . . . . . . . . . . . . . 13 13 27 33 35 36 38 44 47 47 49 49 50 51 52
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
iii
calendar Access to calendar related services . . . . . . . . . calendar for EKA2 Access to calendar related services . . . e32db Interface to the Symbian native DB . . . . . . . . . . . e32dbm DBM implemented using the Symbian native DBMS
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
60 65 70 73
8 Standard Library Support and Extensions 75 8.1 Support for Python Standard Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 8.2 Extensions to Standard Library Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 9 Extending and Embedding 79 9.1 Python/C API Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 9.2 Extending Python for S60 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 10 Terms and Abbreviations A Reporting Bugs Module Index Index 83 87 89 91
iv
CHAPTER
ONE
Introduction
The Python for S60 Platform (Python for S60) simplies application development and provides a scripting solution for the Symbian C++ APIs. This document is for Python for S60 release 1.4.0 nal that is based on Python 2.2.2. The documentation for Python for S60 includes three documents: Getting Started with Python for S60 Platform [5] contains information on how to install Python for S60 and how to write your rst program. This document contains API and other reference material. Programming with Python for S60 Platform [6] contains code examples and programming patterns for S60 devices that can be used as a basis for programs. The Python for S60 as installed on a S60 device consists of: Python runtime package that consists of: Python interpreter DLL Standard and proprietary Python library modules S60 UI application framework adaptation component (a DLL) that connects the scripting domain components to the S60 UI Python script shell package that consists of: an application written in Python and visible in the application menu of the device that provides an execution environment for Python scripts. For S60 platform versions prior to 3rd Edition: Python Installer program for installing Python les on the device, which consists of: A recognizer plug-in that recognizes .py, .pyc, .pyd and .pyo les as belonging to Python. Symbian application written in Python that handles the installation of recognized Python les into the script shell environment. A plugin for the S60 C++ SDK is also available. This plugin makes it possible to run Python scripts in the S60 emulator environment and to compile Python extension modules (PYDs) for the emulator and the device. The Python for S60 developer discussion board [9] on the Forum Nokia Web site is a useful resource for nding out information on specic topics concerning Python for S60. You are welcome to give feedback or ask questions about Python for S60 through this discussion board.
1.1 Scope
This document includes the information required by developers to create applications that use Python for S60, and some advice on extending the platform. 1
1.2 Audience
This guide is intended for developers looking to create programs that use the native features and resources of the S60 phones. The reader should be familiar with the Python programming language (http://www.python.org/) and the basics of using Python for S60 (see Getting Started with Python for S60 Platform [5]).
Chapter 1. Introduction
CHAPTER
TWO
API Summary
All built-in object types of the Python language are supported in the S60 environment. The rest of the programming interfaces are implemented by various library modules as summarized in this chapter.
inbox: see Chapter 6.4 location: see Chapter 6.5 sysinfo: see Chapter 4.2 camera: see Chapter 5.3 audio: see Chapter 6.1 telephone: see Chapter 6.2 calendar: see Chapter 7.2 contacts: see Chapter 7.1 keycapture: see Chapter 5.4 topwindow: see Chapter 5.5 gles: see Chapter 5.6 glcanvas: see Chapter 5.7
CHAPTER
THREE
shell. For more details on this topic, see Programming with Python for S60 Platform [6]. In the rst case the script application is launched via application menu, and it executes in its own process context. The latter case is suitable for development, testing, and trying out new scripts. The Python script shell delivered with Python for S60 package has itself been written in Python. It is a collection of scripts that oer an interactive Python console and a possibility to execute scripts located in the directory of the script shell. Due to this kind of design the scripts are not fully isolated from each other. This means that any changes a script makes in the script shell namespace are visible to other scripts as well. This may be helpful during the development of a script suite, as long as care is taken to avoid unwanted interference between scripts. For some special issues to consider when writing Python scripts to be run in the current Python script shell, see Programming with Python for S60 Platform [6]. These include the arrangements for standard output and the maintenance of the Options menu contents. Note: Note that unlike some previous releases, the current version of the Python for S60 script shell takes care of restoring appuifw.app.menu, appuifw.app.title, appuifw.app.exit key handler, appuifw.app.screen, appuifw.app.body, sys.stderr and ?? after a script has been run, and The application programmer doesnt need to save and restore these settings.
Symbian OS STDLIB implementation has some limitations that are reected at OS module support (see S60 SDK documentation [4]). For example, STDLIB le descriptors cannot be shared between threads, and for that reason, Python le objects cannot either. Sockets as implemented in the S60 version of the socket module. Warning: Trying to use native objects from the wrong thread can crash the interpreter. If display of panic codes is enabled, a typical panic code displayed in this case is KERN-EXEC 3.
CHAPTER
FOUR
A tuple containing the ve components of the Python for S60 version number: major, minor, micro, release tag, and serial. All values except release level are integers; the release tag is a string. A value other than final for the release tag signies a development release. The pys60 version info value corresponding to the Python for S60 version 1.2 is (1, 2, 0, final, 0). s60 version info The SDK version with which this Python was compiled (tuple). The following values are possible: (1, 2) for S60 1st Edition (2, 0) for S60 2nd Edition (2, 6) S60 2nd Edition Feature Pack 2 (2, 8) S60 2nd Edition Feature Pack 3 (3, 0) S60 3rd Edition Examples:
>>> import e32 >>> e32.pys60_version 1.2.0 final >>> e32.pys60_version_info (1, 2, 0, final, 0) >>> e32.s60_version_info (2, 0) >>>
is ui thread() Returns True if the code that calls this function runs in the context of the UI thread; otherwise returns False. start exe(lename, command [,wait ]) Launches the native Symbian OS executable lename (Unicode) and passes it the command string. When wait is set, the function synchronously waits for the exit of the executable and returns a value that describes the exit type. Possible values are 0 for normal exit and 2 for abnormal exit. start server(lename) Starts the Python script in le lename (Unicode) as a server in its own process. Note that appuifw module is not available to a server script. reset inactivity() Resets the timers since the user was last active. As a consequence, the device backlight is normally turned on when this function is invoked. inactivity() Returns the time in seconds since the user of the device was last active.
10
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. The waiter is released.
11
max ramdrive size() Returns the maximum size of the RAM drive on the device. total ram() Returns the amount of RAM memory on the device. free ram() Returns the amount of free RAM memory available on the device. total rom() Returns the amount of read-only ROM memory on the device. ring type() Not supported in 1st Edition! Returns the current ringing type as a string, which can be one of the following: normal, ascending, ring once, beep, or silent. os version() Returns the operating system version number of the device as a three element tuple (major version, minor version, build number). The elements are as follows1 : The major version number, ranging from 0 to 127 inclusive The minor version number, ranging from 0 to 99 inclusive The build number, ranging from 0 to 32767 inclusive. signal bars() Returns the current network signal strength ranging from 0 to 7, with 0 meaning no signal and 7 meaning a strong signal. If using an emulator, value 0 is always returned. signal dbm() Returns the current network signal strength in dBm. This is available SDK 2.8 onwards. If using an emulator value 0 is always returned. sw version() Returns the software version as a Unicode string. On the emulator, returns the hardcoded string uemulator. For example, a software version can be returned as uV 4.09.1 26-02-04 NHL-10 (c) NMP.
1 Descriptions
for these values are based on information found in S60 SDK documentation [4].
12
CHAPTER
FIVE
13
Figure 5.2: The dierent parts of the screen when using the normal layout
14
Figure 5.3: UI layouts. left: normal, middle: large, right: full popup menu A dialog becomes visible as soon as the corresponding Python function has been called. The function returns with the eventual user input or information on the cancellation of the dialog. Form is an exception; it is shown when its execute method is called.
5.1.2 Softkeys
The softkeys are managed by the underlying S60 Platform. When no dialog is visible, the right softkey is bound to application exit and the left one represents an Options menu. Python for S60 oers an interface for manipulating the menu and for binding the Exit key to a Python-callable object (see Section 5.1.4). The native code that implements a dialog also manages the softkeys of the dialog, typically OK and Cancel. When the user input needs to be validated before accepting it and dismissing the dialog, it is best to use Form.
15
For text elds, (text, code) it is Unicode For number elds, it is numeric For date elds, it is seconds since epoch rounded down to the nearest local midnight A simple conrmation query and time query take no initial value and return True/None and seconds since local midnight, correspondingly. All queries return None if the users cancel the dialog. For float query the initial value setting has no eect. multi query(label 1, label 2 ) A two-eld text (Unicode) input dialog. Returns the inputted values as a 2-tuple. Returns None if the users cancel the dialog. note(text [, type [, global ]]) Displays a note dialog of the chosen type with text (Unicode). The default value for type is info, which is automatically used if type is not set. type can be one of the following strings: error, info, or conf. If global (integer) is any other value than zero a global note is displayed. A global note is displayed even if the Python application calling this function is in background. The same set of types is supported as in standard note. popup menu(list [, label ]) A pop-up menu style dialog. list representing the menu contents can be a list of Unicode strings or a list of Unicode string pairs (tuples). The resulting dialog list is then a single-style or a doublestyle list. A single-style list is shown in full; whereas a double-style list shows the items one at a time. Returns None if the user cancels the operation. selection list(choices [, search eld=0 ]) Executes a dialog that allows the users to select a list item and returns the index of the chosen item, or None if the selection is cancelled by the users. choices is a list of Unicode strings. search eld is 0 (disabled) by default and is optional. Setting it to 1 enables a search eld (nd pane) that facilitates searching for items in long lists. If enabled, the search eld appears after you press a letter key. multi selection list(choices [, style=checkbox, search eld=0 ]) Executes a dialog that allows the users to select multiple list items. Returns a tuple of indexes (a pair of Unicode strings) of the chosen items, or empty tuple if the selection is cancelled by the users. choices is a list of Unicode strings. style is an optional string; the default value being checkbox. If checkbox is given, the list will be a checkbox list, where empty checkboxes indicate what items can be marked. The other possible value that can be set for style is checkmark. If checkmark is given, the list will be a markable list, which lists items but does not indicate specically that items can be selected. To select items on a markable list, use the Navigation key to browse the list and the Edit key to select an item. For example views on checkbox and markable lists, see Figure 5.4. search eld is 0 (disabled) by default and is optional. Setting it to 1 enables a search eld (nd pane) that facilitates searching for items in long lists. If enabled, the search eld is always visible with checkbox lists; with markable lists it appears by pressing a letter key. Example:
tuple = appuifw.multi_selection_list(L, style=checkmark, search_field=1)
16
Figure 5.4: Examples of a checkbox list (left) and a markable list (right) body The UI control that is visible in the applications main window. Currently either Text, a Listbox object, Canvas, or None. exit key handler A callable object that is called when the user presses the Exit softkey. exit key handler to None sets it back to the default value. menu This is a list of the following kinds of items: (title, callback) which creates a regular menu item (title, ((title, callback)[... ])) which creates a submenu title (Unicode) is the name of the item and callback the associated callable object. The maximum allowed number of items in a menu, or items in a submenu, or submenus in a menu is 30. Example:
appuifw.app.menu = [(u"Item 1", item1), (u"Submenu 1", ((u"Subitem 1", subitem1), (u"Subitem 2", subitem2)))]
Setting
screen The screen area used by an application. See Figure 5.3 for example screens. The appearance of the application on the screen can be aected by setting one of the following values: normal, large, and full. Examples:
appuifw.app.screen=normal # (a normal screen with title pane and softkeys) appuifw.app.screen=large # (only softkeys visible) appuifw.app.screen=full # (a full screen)
title The title the application that is visible in the applications title pane. Must be Unicode. focus A callable object that is called with integer as parameter (0 = focus lost, 1 = focus regained) when the application receives focus or it is switched to background. Focus is received e.g. when the application is switched from background to foreground or when the focus is regained from screensaver. Similarly when the screensaver is displayed, focus is lost. Examples:
>>> import appuifw >>> def cb(fg):
17
... ... ... ... ... >>> >>> >>> >>> >>>
if(fg): print "foreground" else: print "background" appuifw.app.focus=cb # switch to background, following text is printed from callback: background # switch to foreground, following text is printed from callback: foreground
Note: An improper callback can cause adverse eects. If you, for example, dene a callback which takes no parameters you will receive never-ending TypeError exceptions on the Nokia 6600. orientation Available only for S60 3rdEd. The orientation of the application. The orientation of the application can be one of the following values: automatic (this is the default value), portrait or landscape. Instances of Application type have the following methods: activate tab(index ) Activates the tab index counting from zero. full name() Returns the full name, in Unicode, of the native application in whose context the current Python interpreter session runs. uid() Returns the UID, in Unicode, of the native application in whose context the current Python interpreter session runs. set exit() Requests a graceful exit from the application as soon as the current script execution returns. set tabs(tab texts [,callback=None ]) Sets tabs with given names on them in the navigation bar; tab texts is a list of Unicode strings. When the users navigate between tabs, callback gets called with the index of the active tab as an argument. Tabs can be disabled by giving an empty or one-item tab texts list. layout(layout id ) Note: Available from S60 2ndEd FP3 onwards (inclusive). Returns as a tuple the size and the position of the requested layout id. The logical layouts are outlined partly in Figure 5.2. The position is given from the top left corner. The layout id can be one of the constants dened in module appuifw1 : EScreen Screen. EApplicationWindow Window that lls the entire screen. EStatusPane Indicates common components for most of the applications. EMainPane The application main pane is used in all the applications. EControlPane Control pane. ESignalPane The signal pane is used to indicate signal strength. EContextPane The context pane is used to indicate an active application. ETitlePane Used to indicate the subject or the name of the main pane content.
1 Descriptions
18
EBatteryPane The battery pane is used to indicate battery strength. EUniversalIndicatorPane The universal indicator pane is used to indicate items that require the users attention while browsing applications. ENaviPane The navi pane is used to indicate navigation within an application, to provide context sensitive information to the user while entering or editing data, or to show additional information. EFindPane A xed nd pane is used with lists instead of the nd pop-up window. EWallpaperPane Wallpaper pane. EIndicatorPane The universal indicator pane is used to indicate items that require the users attention while browsing applications. EAColumn Used generally to display small sized graphics or heading texts. EBColumn Used generally to display large sized icons or heading texts. ECColumn Used generally to display data entered by the user. Overlaps with the D column. EDColumn Used generally to display additional icons. Overlaps with the C column. EStaconTop Top part of status and control panes in landscape layout. EStaconBottom Bottom part of status and control panes in landscape layout. EStatusPaneBottom Bottom part of status pane in landscape layout. EControlPaneBottom Bottom part of control pane in landscape layout. EControlPaneTop Top part of control pane in landscape layout. EStatusPaneTop Top part of status pane in landscape layout. Example:
>>> import appuifw >>> appuifw.app.layout(appuifw.EMainPane) ((176, 144), (0, 44)) >>> # size and position (x, y) of the main pane in Nokia N70
19
value, depending on type: Unicode string, numeric, oat (seconds since Unix epoch rounded down to the nearest local midnight), oat (seconds since local midnight), ([choice label ...], index) of oat. For float type the initial value setting might not be shown in the UI. Form can also be congured and populated after construction. The conguration ags are visible as an attribute. Form implements the list protocol that can be used for setting the form elds, as well as obtaining their values after the dialog has been executed. Instances of Form type have the following attributes: flags This attribute holds the values of the various conguration ags. Currently supported ags are: FFormEditModeOnly When this ag is set, the form remains in edit mode while execute runs. FFormViewModeOnly When this ag is set, the form cannot be edited at all. FFormAutoLabelEdit This ag enables support for allowing the end-users to edit the labels of the form elds. FFormAutoFormEdit This ag enables automatic support for allowing the end-users to add and delete the form elds. Note that this is an experimental feature and is not guaranteed to work with all SDK versions. FFormDoubleSpaced When this ag is set, double-spaced layout is applied when the form is executed: one eld takes two lines, as the label and the value eld are on dierent lines. menu A list of (title, callback) pairs, where each pair describes an item in the forms menu bar that is active while the dialog is being executed. title (Unicode) is the name of the item and callback the associated callable object. save hook This attribute can be set to a callable object that receives one argument and returns a Boolean value. It gets called every time the users want to save the contents of an executing Form dialog. A candidate list for new form content - a list representing the currently visible state of the UI - is given as an argument. The list can be modied by save hook. If save hook returns True, the candidate list is set as the new contents of the form. Otherwise, the form UI is reset to reect the eld list contained in Form object. Instances of Form type have the following methods: execute() Executes the dialog by making it visible on the UI. insert(index, eld descriptor ) Inserts the eld descriptor into the Form before the given index . pop() Removes the last eld descriptor from the Form and returns it. length() the number of eld descriptors in the form. The subscript notation f[i] can be used to access or modify the i-th element of the form f. Same limitations as discussed above in the context of the ag FFormAutoFormEdit apply to modifying a form while it is executing. The ability to change the schema of a form while it is executing is an experimental feature.
20
Figure 5.5: Examples of the options available for Text type Instances of Text type have the following attributes: color The color of the text. color supports the same color representation models as the graphics module. For the supported color representation models, see Section 5.2. focus A Boolean attribute that indicates the focus state of the control. Editor control also takes the ownership of the navigation bar, and this feature is needed to enable the usage of this control in applications that use the navigation bar - for example, navigation tabs. font The font of the text. There are two possible ways to set this attribute: Using a supported Unicode font, for example u"Latin12". Trying to set a font which is not supported by the device has no eect. A list of supported fonts can be retrieved by using appuifw.available fonts. Example, setting font:
t = appuifw.Text() t.font = u"albi17b" # sets font to Albi 17 bold t.font = u"LatinPlain12" # sets font to Latin Plain 12
Using one of the default device fonts that are associated with the following labels (plain strings): annotation, title, legend, symbol, dense, normal Example, setting font:
t.font = "title" # sets font to the one used in titles
The attribute value retrieved is always a Unicode string. If the font has been set with a label, for example, title, the attribute will retrieve the font associated with that label. highlight color The highlight color of the text. highlight color supports the same color representation models as the graphics module. For the supported color representation models, see Section 5.2. style The style of the text. The ags for this attribute are dened in the appuifw module. These ags can be combined by using the binary operator |. The ags can be divided into two types: text style and text highlight. Text style ags can be freely combined with each other. However, one or more text style ags can be combined with only one text highlight ag. The ags are: Text style: 5.1. appuifw Interface to the S60 GUI framework 21
STYLE BOLD Enables bold text. STYLE UNDERLINE Enables underlined text. STYLE ITALIC Enables italic text. STYLE STRIKETHROUGH Enables strikethrough. Text highlight: HIGHLIGHT STANDARD Enables standard highlight. HIGHLIGHT ROUNDED Enables rounded highlight. HIGHLIGHT SHADOW Enables shadow highlight. Only one highlight is allowed to be used at once. Therefore, it is possible to combine only one highlight with one or more text styles. Examples:
t = appuifw.Text() # These and other similar values and combinations are valid: t.style = appuifw.STYLE_BOLD t.style = appuifw.STYLE_UNDERLINE t.style = appuifw.STYLE_ITALIC t.style = appuifw.STYLE_STRIKETHROUGH t.style = (appuifw.STYLE_BOLD| appuifw.STYLE_ITALIC| appuifw.STYLE_UNDERLINE) # These t.style t.style t.style values are valid: = appuifw.HIGHLIGHT_STANDARD = appuifw.HIGHLIGHT_ROUNDED = appuifw.HIGHLIGHT_SHADOW
# This combination is NOT valid: # Invalid code, do not try! t.style = (appuifw.HIGHLIGHT_SHADOW|appuifw.HIGHLIGHT_ROUNDED)
Instances of Text type have the following methods: add(text) Inserts the Unicode string text to the current cursor position. bind(event code, callback ) Binds the callable Python object callback to event event code. The key codes are dened in the key codes library module. The call bind(event code, None) clears an existing binding. In the current implementation the event is always passed also to the underlying native UI control. clear() Clears the editor. delete([pos=0, length=len() ]) Deletes length characters of the text held by the editor control, starting from the position pos. get pos() Returns the current cursor position. len() Returns the length of the text string held by the editor control.
22
get([pos=0, length=len() ]) Retrieves length characters of the text held by the editor control, starting from the position pos. set(text) Sets the text content of the editor control to Unicode string text. set pos(cursor pos) Sets the cursor to cursor pos.
Figure 5.6: Listbox with icons An instance of this UI control type is visible as a listbox, also known as a list in Symbian, that can be congured to be a single-line item or a double-item listbox. Figure 5.6 shows a single-line item Listbox with icons. For more information on the MBM and MIF formats, see Section 5.1.8. class Listbox(list, callback ) Creates a Listbox instance. A callable object callback gets called when a listbox selection has been made. list denes the content of the listbox and can be one of the following: A normal (single-line item) listbox: a list of Unicode strings, for example [unicode string item1, unicode string item2] A double-item listbox: a two-element tuple of Unicode strings , for example [(unicode string item1, unicode string item1description), (unicode string item2, unicode string item2description)] A normal (single-line item) listbox with graphics: a two-element tuple consisting of a Unicode string and an Icon object, for example [(unicode string item1, icon1), (unicode string item2, icon2)]. A double-item listbox with graphics: a three-element tuple consisting of two Unicode strings and one Icon object, for example [(unicode string item1, unicode string item1description, icon1), (unicode string item2, unicode string item2description, icon2)] Example: To produce a normal (single-line item) listbox with graphics:
icon1 = appuifw.Icon(u"z:\\system\\data\\avkon.mbm", 28, 29) icon2 = appuifw.Icon(u"z:\\system\\data\\avkon.mbm", 40, 41) entries = [(u"Signal", icon1), (u"Battery", icon2)] lb = appuifw.Listbox(entries, lbox_observe)
23
bind(event code, callback ) Binds the callable Python object callback to event event code. The key codes are dened in the key codes library module. The call bind(event code, None) clears an existing binding. In the current implementation the event is always passed also to the underlying native UI control. current() Returns the currently selected items index in the Listbox. set list(list [, current ]) Sets the Listbox content to a list of Unicode strings or a list of tuples of Unicode strings. The accepted structures of list are the same as in the Listbox constructor. The optional argument current is the index of the focused list item.
method.
25
Keycode EKeyLeftSoftkey EKeyYes EKeyMenu EKey0...9 EKeyStar EKeyLeftArrow EKeyUpArrow EKeySelect EKeyRightArrow EKeyDownArrow EKeyRightSoftkey EKeyNo EKeyBackspace EKeyEdit EKeyHash
Scancode EScancodeLeftSoftkey EScancodeYes EScancodeMenu EScancode0...9 EScancodeStar EScancodeLeftArrow EScancodeUpArrow EScancodeSelect EScancodeRightArrow EScancodeDownArrow EScancodeRightSoftkey EScancodeNo EScancodeBackspace EScancodeEdit EScancodeHash
Figure 5.7: Keycodes and scancodes for phone keys usable from Python applications
26
Instances of Canvas type have the following attribute: size A two-element tuple that contains the current width and height of the Canvas as integers. Instances of Canvas type have the same standard drawing methods that are documented in Section 5.2.
27
28
1: Black and white, 1 bit per pixel 8: 256 gray shades, 8 bits per pixel 24: 16.7 million colors, 24 bits per pixel Valid values for compression are: best: The highest possible compression ratio, the slowest speed fast: The fastest possible saving, moderate compression no: No compression, very large le size default: Default compression, a compromise between le size and speed If callback is given, the operation is asynchronous. When the saving is complete, the callback is called with the result code. stop() Stops the current asynchronous operation, if any. If an asynchronous call is not in progress, this method has no eect. Image objects have the following attribute: size A two-element tuple that contains the size of the Image. Read-only.
[(1,221L),(3,4),[5.12,6]): A sequence of three coordinates (1,5): A sequence of one coordinate [(1,5)]: A sequence of one coordinate [[1,5]]: A sequence of one coordinate Examples of invalid coordinate sequences: Invalid code, do not use! []: An empty sequence (1,2,3): Odd number of elements in a at sequence [(1,2),(3,4),None]: Contains an invalid element ([1,2],3,4): Mixing the at and nested form is not allowed Color representation All methods that take color arguments accept the following two color representations: A three-element tuple of integers in the range from 0 to 255 inclusive, representing the red, green, and blue components of the color. An integer of the form 0xrrggbb, where rr is the red, gg the green, and bb the blue component of the color. For 12 and 16 bit color modes the color component values are simply truncated to the lower bit depth. For the 8-bit grayscale mode images the color is converted into grayscale using the formula (2*r+5*g+b)/8, rounded down to the nearest integer. For 1-bit black and white mode images the color is converted into black (0) or white (1) using the formula (2*r+5*g+b)/1024. Examples of valid colors: 0xffff00: Bright yellow 0x004000: Dark green (255,0,0): Bright red 0: Black 255: Bright blue (128,128,128): Medium gray Examples of invalid colors: Invalid code, do not use! (0,0.5,0.9): Floats are not supported #ff80c0: The HTML color format is not supported (-1,0,1000): Out-of-range values (1,2): The sequence is too short [128,128,192]: This is not a tuple
30
Font specications A font can be specied in three ways: None, meaning the default font a Unicode string that represents a full font name, such as uLatinBold19 a plain string symbolic name that refers to a font setting currently specied by the UI framework as a two or three element tuple, where the rst element is the font name (unicode or string) or None for default font the second element is the font height in pixels or None for default size the third (optional) element is the ags applied to the font or None for default options. The ags are the following: FONT BOLD bold FONT ITALIC italic FONT SUBSCRIPT subscript FONT SUPERSCRIPT superscript FONT ANTIALIAS forces the font to be antialiased FONT NO ANTIALIAS forces the font to not be antialiased You can combine the ags with the binary or operator . For example, the ags setting FONT BOLD|FONT ITALIC will produce text that is both bold and italic. Note: Antialiasing support is only available for scalable fonts. You can obtain a list of all available fonts with the appuifw module function available fonts. The symbolic names for UI fonts are: normal dense title symbol legend annotation Since background processes have no access to the UI framework, these symbolic names are not supported in them. You need to specify the full font name. Common Methods of Drawable Objects line(coordseq [, <options> ]) Draws a line connecting the points in the given coordinate sequence. For more information about the choices available for options, see Section 5.2.4. polygon(coordseq [, <options> ]) Draws a line connecting the points in the given coordinate sequence, and additionally draws an extra line connecting the rst and the last point in the sequence. If a ll color or pattern is specied, the polygon is lled with that color or pattern. For more information about the choices available for options, see Section 5.2.4. 5.2. graphics A graphics related services package 31
rectangle(coordseq [, <options> ]) Draws rectangles between pairs of coordinates in the given sequence. The coordinates specify the top-left and the bottom- right corners of the rectangle. The sequence must have an even number of coordinates. For more information about the choices available for options, see Section 5.2.4. ellipse(coordseq [, <options> ]) Draws ellipses between pairs of coordinates in the given sequence. The coordinates specify the topleft and bottom-right corners of the rectangle inside which the ellipse is contained. The sequence must have an even number of coordinates. For more information about the choices available for options, see Section 5.2.4. pieslice(coordseq, start, end [, <options> ]) Draws pie slices contained in ellipses between pairs of coordinates in the given sequence. The start and end parameters are oats that specify the start and end points of pie slice as the starting and ending angle in radians. The angle 0 is to the right, the angle pi/2 is straight up, pi is to the left and-pi/2 is straight down. coordseq is interpreted the same way as for the ellipse method. For more information about the choices available for options, see Section 5.2.4. arc(coordseq, start, end [, <options> ]) Draws arcs contained in ellipses between pairs of coordinates in the given sequence. The start and end parameters are oats that specify the start and end points of pie slice as the starting and ending angle in radians. The angle 0 is to the right, the angle pi/2 is straight up, pi is to the left and-pi/2 is straight down. coordseq is interpreted the same way as for the ellipse method. For more information about the choices available for options, see Section 5.2.4. point(coordseq [, <options> ]) Draws points in each coordinate in the given coordinate sequence. If the width option is set to greater than 1, draws a crude approximation of a circle lled with the outline color in the locations. Note that the approximation is not very accurate for large widths; use the ellipse method if you need a precisely formed circle. For more information about the choices available for options, see Section 5.2.4. clear([color=0x ]) Sets the entire surface of the drawable to the given color, white by default. text(coordseq, text [ll=0, font=None ]) Draws the given text in the points in the given coordinate sequence with the given color (default value is black) and the given font. The font specication format is described above. measure text(text [font=None, maxwidth=-1, maxadvance=-1 ]) Measures the size of the given text when drawn using the given font. Optionally you can specify the maximum width of the text or the maximum amount the graphics cursor is allowed to move (both in pixels). Returns a tuple of three values: the bounding box for the text as a 4-tuple: (topleft-x, topleft-y, bottomright-x, bottomright-y) the number of pixels the graphics cursor would move to the right the number of characters of the text that ts into the given maximum width and advance blit(image [,target=(0,0), source=((0,0),image.size), mask=None, scale=0 ]) Copies the source area from the given image to the target area in this drawable. The source area is copied in its entirety if mask is not given or is set to None. If the mask is given, the source area is copied where the mask is white. mask can be either None, a 1-bit (black and white) Image or (on S60 2nd edition FP2 and later) a grayscale Image, and must be of the same size as the source image. A grayscale mask acts as an alpha channel, i.e. partial transparency. target and source specify the target area in this image and the source area in the given source. They are coordinate sequences of one or two coordinates. If they specify one coordinate, it is interpreted as the upper-left corner for the area; if they specify two coordinates, they are interpreted as the top-left and bottom-right corners of the area. If scale is other than zero, scaling is performed on the y while copying the source area to the 32 Chapter 5. User Interface and Graphics
target area. If scale is zero, no scaling is performed, and the size of the copied area is clipped to the smaller of source and target areas. Note that a blit operation with scaling is slower than one without scaling. If you need to blit the same Image many times in a scaled form, consider making a temporary Image of the scaling result and blitting it without scaling. Note also that the scaling performed by the blit operation is much faster but of worse quality than the one done by the resize method, since the blit method does not perform any antialiasing.
for some of the values are based on information found in S60 SDK documentation [4] more information, see e.g. http://en.wikipedia.org/wiki/JPEG.
33
Note that there is variety between the devices and the supported formats. size is the resolution of the image. The default value is (640, 480). The following sizes are supported, for example, in Nokia 6630: (1280, 960), (640, 480) and (160, 120). ash is the ash mode setting. The default value is none. The following ash mode settings are supported: none No ash. Default value, always supported auto Flash will automatically re when required forced Flash will always re fill in Reduced ash for general lighting red eye reduce Red-eye reduction mode zoom is the digital zoom factor. It is assumed to be on a linear scale from 0 to the maximum zoom value allowed in the device. The default value is 0, meaning that zoom is not used. exposure is the exposure adjustment of the device. Exposure is a combination of lens aperture and shutter speed used in taking a photograph. The default value is auto. The following exposure modes are supported: auto Sets exposure automatically. Default value, always supported night Night-time setting for long exposures backlight Backlight setting for bright backgrounds center Centered mode for ignoring surroundings white balance can be used to adjust white balance to match the main source of light. The term white balance refers to the color temperature of the current light. A digital camera requires a reference point to represent white. It will then calculate all the other colors based on this white point. The default value for white balance is auto and the following white balance modes are supported: auto Sets white balance daylight Sets white balance cloudy Sets white balance tungsten Sets white balance fluorescent Sets white balance flash Sets white balance automatically. Default value, always supported to normal daylight to overcast daylight to tungsten lament lighting to uorescent tube lighting to ash lighting
position is the camera used if the device, such as Nokia 6680, has several cameras. In Nokia 6680, the camera pointing to the user of the device is located in position 1, whereas the one pointing away from the user is located in position 0. The default position is 0. If some other application is using the camera, this operation fails, with error SymbianError: KErrInUse. Invoking this function right after the device boot, might result in SymbianError: KErrNotReady error.
34
start finder(callable [, backlight on=1, size=main pane size ]) Starts the camera viewnder and binds a callback to receive Image format feed. When a new viewnder frame is ready the callback is invoked with the Image as parameter. The optional parameter backlight on determines whether the device backlight is kept on when the camera view nder is in operation. By default, the backlight is on (1 = on, 0 = o). The optional parameter size (of type tuple, e.g. (176, 144)) can be used to change the size of the Image received in the callback. The default size is the same as the applications main pane size. Example view nder code:
import appuifw import camera def cb(im): appuifw.app.body.blit(im) import graphics appuifw.app.body=appuifw.Canvas() camera.start_finder(cb)
stop finder() Stops the viewnder. release() Releases the camera After invocation other applications can access the camera hardware.
35
forwarding Species whether captured key events are forwarded to other applications or not. Either has value 1 or 0. Can be read and written. start() Starts the actual capturing of key events. stop() Stops the actual capturing of key events. last key() Returns last key code that is captured.
5.5 topwindow Interface for creating windows that are shown on top of other applications.
The topwindow module oers an API for creating windows that are shown on top of other applications and managing the content of these windows. Images can be inserted into the windows and the background color, visibility, corner type and shadow of the window can be manipulated. topwindow extension does not provide sophisticated drawing capabilities by any means but rather relies on services provided by the graphics extension: topwindow allows graphics Image objects to be put into the windows that are represented by TopWindow objects. TopWindow object provides mainly only two services: TopWindow objects can be shown or hidden and Images can be put into the windows. However, several images can be added into one TopWindow object and several TopWindow objects can be created and shown. Since the images can be manipulated using the graphics extension this makes it possible to create many kind of content to the TopWindow objects.
remove image(image [,position ]) Removes the image from the window. Mandatory parameter image must be a graphics.Image object. Parameter position may specify the top-left corner coordinates of the image or the rectangular area of the image. If only image parameter is given, all the pictures representing this image object are removed from the window. If both parameters are given, only the picture that matches both parameters is removed. Example:
36
position Species the coordinates of the top left corner of the window. Can be read and written. Example:
position = (10, 20)
size Species the size of the window. Can be read and written. Example:
size = (100, 200)
images The images inserted into the window. Dened as a list of tuple objects. Each tuple contains a graphics.Image object and the position of the image. The position may specify the top-left coordinate of the image and optionally also the bottom-right coordinate of the image. Parameter (x,y) species the top-left coordinate, but does not resize the image while parameter like (x1,y1,x2,y2) species both the top-left and bottom-right coordinates and possibly also resizes the image. Can be read and written. Also see the add image() and remove image() methods. Example:
images = [(image1,(x1,y1)), (image2,(x1,y1,x2,y2)), (image3,(50,50,100,100))]
sets the window content to be 3 images. image2 and image3 are possibly resized while the image1 is not) shadow Species if the shadow of the window is shown and the length of the shadow. Can be read and written. Setting shadow = 0 makes the shadow invisible. Example: shadow = 5 corner type Species the corner type of the window. Can be read and written. Corner type can be one of the following values: square corner1 corner2 corner3 corner5 Example: corner type = square maximum size Returns the maximum size of the window as a tuple (width, height). Read only property. background color The background color of the window as an integer (e.g. 0xaabbcc). The two greatest hexadecimal digits specify the red, the next two specify the blue and the last ones specify the green color. Can be read and written. Example: background color = 0xffffff (sets the white color) visible Can be set to 0 or 1. 1 means that window is visible, 0 means that it is not. Can be read and written. Also see the show and hide methods.
5.5. topwindow Interface for creating windows that are shown on top of other applications.
37
38
added. Both of sets of functions are documented below. If a function is not listed here its Python version should exactly match the C version dened in the ocial OpenGL ES 1.0 and 1.1 specications. OpenGL ES 1.0 glColorPointer(size, type, stride, sequence) Parameter sequence must be either a gles.array object or some other Python sequence object. gles.array objects require less processing and can be therefore slightly faster. If gles.array object is used, the type and dimension of its data are ignored and size and type are used instead. glColorPointerub(sequence) Special Python version of glColorPointer that accepts either a gles.array object or some other Python sequence object. Other parameters of glColorPointer will be determined as follows: size If sequence is an instance of gles.array, its dimension is used; otherwise the length of sequence is used. type GL UNSIGNED BYTE stride 0 glColorPointerf(sequence) Special Python version of glColorPointer that behaves exactly as glColorPointerub except GL FLOAT is used as type. glColorPointerx(sequence) Special Python version of glColorPointer that behaves exactly as glColorPointerub except GL FIXED is used as type. glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data) Parameter data must be either a gles.array or a Python string. glCompressedTexSubImage2D(target, level, xoset, yoset, width, height, format, imageSize, data) Parameter data must be either a gles.array or a Python string. glDeleteTextures(sequence) Parameter sequence must be a Python sequence containing integers. glDrawElements(mode, count, type, indices) Parameter indices must be either a gles.array or some other Python sequence object. gles.array objects require less processing and can be therefore slightly faster. If gles.array object is used, the type of its data is ignored and type is used instead. glDrawElementsub(mode, indices) Special Python version of glDrawElements that uses length of the sequence indices as count and GL UNSIGNED BYTE as type. glDrawElementsus(mode, indices) Special Python version of glDrawElements that uses length of the sequence indices as count and GL UNSIGNED SHORT as type. glFogv(pname, params) Parameter params must be a Python sequence containing oat values. glFogxv(pname, params) Parameter params must be a Python sequence containing integer values. glGenTextures(n) The generated texture names are returned in a Python tuple. glGetIntegerv(pname) The values are returned in a Python tuple. glGetString(name) The value is return as a Python string. glLightModelfv(pname, params) Parameter params must be a Python sequence containing oat values. 5.6. gles Bindings to OpenGL ES 39
glLightModelxv(pname, params) Parameter params must be a Python sequence containing integer values. glLightfv(light, pname, params) Parameter params must be a Python sequence containing oat values. glLightxv(light, pname, params) Parameter params must be a Python sequence containing integer values. glLoadMatrixf(m) Parameter m must be a Python sequence containing oat values. The sequence is attened before its items are read. glLoadMatrixx(m) Parameter m must be a Python sequence containing integer values. The sequence is attened before its items are read. glMaterialfv(face, pname, params) Parameter params must be a Python sequence containing oat values. glMaterialxv(face, pname, params) Parameter params must be a Python sequence containing integer values. glMultMatrixf(m) Parameter m must be a Python sequence containing oat values. The sequence is attened before its items are read. glMultMatrixx(m) Parameter m must be a Python sequence containing integer values. The sequence is attened before its items are read. glNormalPointer(type, stride, sequence) Parameter sequence must be either a gles.array object or some other Python sequence object. gles.array objects require less processing and can be therefore slightly faster. If gles.array object is used, the type of its data is ignored and type is used instead. glNormalPointerb(sequence) Special Python version of glNormalPointer that uses type GL BYTE and stride 0. glNormalPointers(sequence) Special Python version of glNormalPointer that uses type GL SHORT and stride 0. glNormalPointerf(sequence) Special Python version of glNormalPointer that uses type GL FLOAT and stride 0. glNormalPointerx(sequence) Special Python version of glNormalPointer that uses type GL FIXED and stride 0. glReadPixels(x, y, width, height, format, type) The pixel data read is returned in a Python string. glTexCoordPointer(size, type, stride, sequence) Parameter sequence must be either a gles.array object or some other Python sequence object. gles.array objects require less processing and can be therefore slightly faster. If gles.array object is used, the dimension and type of its data are ignored and size and type are used instead. glTexCoordPointerb(sequence) Special Python version of glTexCoordPointer that accepts either a gles.array object or some other Python sequence object. Other parameters of glTexCoordPointer will be determined as follows: size If sequence is an instance of gles.array, its dimension is used; otherwise the length of sequence is used. type GL BYTE stride 0 glTexCoordPointers(sequence) 40 Chapter 5. User Interface and Graphics
Special Python version of glTexCoordPointer that behaves exactly as glTexCoordPointerb except GL SHORT is used as type. glTexCoordPointerf(sequence) Special Python version of glTexCoordPointer that behaves exactly as glTexCoordPointerb except GL FLOAT is used as type. glTexCoordPointerx(sequence) Special Python version of glTexCoordPointer that behaves exactly as glTexCoordPointerb except GL FIXED is used as type. glTexEnvfv(face, pname, params) Parameter params must be a Python sequence containing oat values. glTexEnvxv(face, pname, params) Parameter params must be a Python sequence containing integer values. glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels) Parameter pixels must be either a Python string, a gles.array object, or graphics.Image object. Python strings are taken as literal data with no conversion. The dimension and type of data in gles.array objects are ignored: the raw data in the array is used. Use of graphics.Image objects is limited to only some combinations of format and type. Table 5.6.3 below shows the accepted combinations. To get the best results and performance, the CFbsBitmap object in the graphics.Image object should be in the equivalent display mode, also shown in the table below. Otherwise, the CFbsBitmap object will be rst converted to the equivalent display mode before reading its pixel data, which can degrade the visual quality in some cases.
Table 5.1: Legal combinations of format and type with the equivalent Symbian display mode. format GL LUMINANCE, GL ALPHA GL RGB GL RGB type GL UNSIGNED BYTE GL UNSIGNED BYTE GL UNSIGNED SHORT 5 6 5 The equivalent display mode EGray256 EColor16M EColor64K
glTexSubImage2D(target, level, xoset, yoset, width, height, format, type, pixels) The handling of pixels is the same as with glTexImage2D. glVertexPointer(size, type, stride, sequence) Parameter sequence must be either a gles.array object or some other Python sequence object. gles.array objects require less processing and can be therefore slightly faster. If gles.array object is used, the dimension and type of its data are ignored and size and type are used instead. glVertexPointerb(sequence) Special Python version of glVertexPointer that accepts either a gles.array object or some other Python sequence object. Other parameters of glVertexPointer will be determined as follows: size If sequence is an instance of gles.array, its dimension is used; otherwise the length of sequence is used. type GL BYTE stride 0 glVertexPointers(sequence) Special Python version of glVertexPointer that behaves exactly as glVertexPointerb except GL SHORT is used as type. glVertexPointerf(sequence) Special Python version of glVertexPointer that behaves exactly as glVertexPointerb except GL FLOAT is used as type. glVertexPointerx(sequence) Special Python version of glVertexPointer that behaves exactly as glVertexPointerb except 5.6. gles Bindings to OpenGL ES 41
GL FIXED is used as type. OpenGL ES 1.1 glBufferData(target, size, data, usage) Parameter data must be a gles.array object. If size is -1, the in-memory size of data is used in its place. glBufferDatab(target, data, usage) Special Python version of glBufferData that accepts either a gles.array object or some other Python sequence object for data. If gles.array object is used, its in-memory size in bytes is used as size. Other sequences are rst converted to at lists of GL BYTE data by casting. The length of the resulting sequence in bytes is used as size. glBufferDataub(target, data, usage) Special Python version of glBufferData that works exactly like glBufferDatab except GL UNSIGNED BYTE is used instead of GL BYTE. glBufferDatas(target, data, usage) Special Python version of glBufferData that works exactly like glBufferDatab except GL SHORT is used instead of GL BYTE. glBufferDataus(target, data, usage) Special Python version of glBufferData that works exactly like glBufferDatab except GL UNSIGNED SHORT is used instead of GL BYTE. glBufferDataf(target, data, usage) Special Python version of glBufferData that works exactly like glBufferDatab except GL FLOAT is used instead of GL BYTE. glBufferDatax(target, data, usage) Special Python version of glBufferData that works exactly like glBufferDatab except GL FIXED is used instead of GL BYTE. glBufferSubData(target, size, data, usage) Parameter data must be a gles.array object. If size is -1, the in-memory size of data is used in its place. glBufferSubDatab(target, data, usage) Special Python version of glBufferSubData that accepts either a gles.array object or some other Python sequence object for data. If gles.array object is used, its in-memory size (in bytes) is used as size. Other sequences are rst converted to at lists of GL BYTE data by casting. The length of the resulting sequence is used as size. glBufferSubDataub(target, data, usage) Special Python version of glBufferSubData that works exactly like glBufferSubDatab except GL UNSIGNED BYTE is used instead of GL BYTE. glBufferSubDatas(target, data, usage) Special Python version of glBufferSubData that works exactly like glBufferSubDatab except GL SHORT is used instead of GL BYTE. glBufferSubDataus(target, data, usage) Special Python version of glBufferSubData that works exactly like glBufferSubDatab except GL UNSIGNED SHORT is used instead of GL BYTE. glBufferSubDataf(target, data, usage) Special Python version of glBufferSubData that works exactly like glBufferSubDatab except GL FLOAT is used instead of GL BYTE. glBufferSubDatax(target, data, usage) Special Python version of glBufferSubData that works exactly like glBufferSubDatab except GL FIXED is used instead of GL BYTE. glClipPlanef(plane, equation)
42
Parameter equation must be a Python sequence that contains four oat values. glClipPlanex(plane, equation) Parameter equation must be a Python sequence that contains four integer values. glDeleteBuffers(buers) Parameter buers must be a Python sequence that contains integer values. glDrawTexsvOES(coords) Parameter coords must be a Python sequence that contains integer values. glDrawTexivOES(coords) Parameter coords must be a Python sequence that contains integer values. glDrawTexfvOES(coords) Parameter coords must be a Python sequence that contains oat values. glDrawTexfvOES(coords) Parameter coords must be a Python sequence that contains integer values. glGenBuffers(n) The generated buer names are returned in a Python tuple. glGetBooleanv(pname) The values are returned in a Python tuple. glGetBufferParameteriv(target, pname) The value is returned as an integer. glGetClipPlanef(plane) The values are returned in a Python tuple. glGetClipPlanef(plane) The values are returned in a Python tuple. glGetFixedv(pname) The values are returned in a Python tuple. glGetFloatv(pname) The values are returned in a Python tuple. glGetLightfv(light, pname) The values are returned in a Python tuple. glGetLightxv(light, pname) The values are returned in a Python tuple. glGetMaterialfv(face, pname) The values are returned in a Python tuple. glGetMaterialxv(face, pname) The values are returned in a Python tuple. glGetTexEnvf(face, pname) The values are returned in a Python tuple. glGetTexEnvx(face, pname) The values are returned in a Python tuple. glGetTexParameterf(target, pname) The value is returned as a oat. glGetTexParameterx(target, pname) The value is returned as an integer. glMatrixIndexPointerOES(size, type, stride, sequence) Parameter sequence must be either a gles.array object or some other Python sequence object. gles.array objects require less processing and can be therefore slightly faster. If gles.array object is used, the dimension and type of its data are ignored and size and type are used instead.
43
glMatrixIndexPointerOESub(sequence) Special Python version of glMatrixIndexPointerOES that accepts either a gles.array object or some other Python sequence object. Other parameters of glMatrixIndexPointerOES will be determined as follows: size If sequence is an instance of gles.array, its dimension is used; otherwise the length of sequence is used. type GL UNSIGNED BYTE stride 0 glPointParameterfv(pname, params) Parameter params must be a Python sequence containing oat values. glPointParameterxv(pname, params) Parameter params must be a Python sequence containing integer values. glPointSizePointerOES(type, stride, sequence) Parameter sequence must be either a gles.array object or some other Python sequence object. gles.array objects require less processing and can be therefore slightly faster. If gles.array object is used, the type of its data is ignored and type is used instead. glPointSizePointerOESf(sequence) Special Python version of glPointSizePointerOES uses GL FLOAT as type and 0 as stride. glPointSizePointerOESx(target, data, usage) Special Python version of glPointSizePointerOES uses GL FIXED as type and 0 as stride. glWeightPointerOES(size, type, stride, sequence) Parameter sequence must be either a gles.array object or some other Python sequence object. gles.array objects require less processing and can be therefore slightly faster. If gles.array object is used, the dimension and type of its data are ignored and size and type are used instead. glWeightPointerOESf(sequence) Special Python version of glWeightPointerOES that accepts either a gles.array object or some other Python sequence object. Other parameters of glWeightPointerOES will be determined as follows: size If sequence is an instance of gles.array, its dimension is used; otherwise the length of sequence is used. type GL FLOAT stride 0 glWeightPointerOESx(sequence) Special Python version of glWeightPointerOES that behaves exactly as glWeightPointerOESf except GL FIXED is used as type.
44
the same program, as each GLCanvas object is automatically made current when it is created and it remains current until it is destroyed or makeCurrent of some other GLCanvas object is called. class GLCanvas(redraw callback, [event callback=None, resize callback=None, attributes=None ]) Constructs a new GLCanvas object that can be used as a UI control for displaying OpenGL ES graphics. Parameters redraw callback , event callback , and resize callback have the same meaning as with appuifw module Canvas. Using redraw callback to specify the OpenGL ES drawing is preferred as it will be automatically called by drawNow method. Parameter attributes can be used to specify attributes used in EGL cong selection. It must be a Python dictionary where keys are EGL attribute names (which are dened in the glcanvas module) and values are integers dening the desired attribute values. Unless specied in attributes, EGL BUFFER SIZE is set to value based on the display mode of the window owned by the underlying CCoeControl object and EGL DEPTH SIZE is set to 16. Attributes specied in attributes are given to eglChooseConfig. Refer to the EGL specication for a detailed list of cong attributes and explanation of how the selection of EGL congs works. The new GLCanvas object will be made current when the constructor returns so makeCurrent does not have to be called before starting to use OpenGL ES calls. bind(key code, c) Sets a callback to be called when a specic key is pressed. Parameter key code should be one of the standard Symbian key codes dened in key codes. Parameter c must be a callable object. drawNow() Calls the redraw callback (if set) and then calls eglSwapBuffers to render and display the OpenGL ES graphics. makeCurrent() Makes this GLCanvas object current, meaning that it will be used to display the results of the subsequent OpenGL ES calls. In EGL terms this means that the EGL context and surface held by this object will be passed to eglMakeCurrent. Using makeCurrent makes it possible to use several GLCanvas objects in a single application: the receiver of the OpenGL ES calls can be switched with makeCurrent easily.
45
46
CHAPTER
SIX
47
interval it plays the audio le one time. times denes the number of times the audio le is played, the default being 1 . If the audio le is played several times, interval gives the time interval between the subsequent plays in microseconds. The optional callback is called when the playing starts and when the end of the sound le is reached. The callback should take three parameters: the previous state, the current state and the possible error code. The possible states given as parameters to the callback are data items in the module audio. Other issues: Calling play(audio.KMdaRepeatForever) will repeat the le forever. If an audio le is played but not stopped before exiting, the Python script will leave audio playing on; therefore stop needs to be called explicitly prior to exit. Currently the module does not support playing simultaneous audio les, calling play to a second Sound instance while another audio le is playing, stops the earlier audio le and starts to play the second Sound instance. Calling play while a telephone call is ongoing plays the sound le to uplink. In some devices the sound le is also played to the device speaker. Calling play when already playing or recording results in RuntimeError. Calling stop prior to play will prevent this from happening. stop() Stops playback or recording of an audio le. record() Starts recording audio data to a le. If the le already exists, the operation appends to the le. For Nokia devices, WAV is typically supported for recording. For more information on the audio types supported by dierent devices, see the Forum Nokia Web site [7] and S60 Platform Web site [8]. Other issues: Calling record while a telephone call is ongoing starts the recording of the telephone call. Calling record when already playing or recording results in RuntimeError. Calling stop prior to record will prevent this from happening. close() Closes an opened audio le. state() Returns the current state of the Sound type instance. The dierent states (constants) are dened in the audio module. The possible states2 are: ENotReady The Sound object has been constructed but no audio le is open. EOpen An audio le is open but no playing or recording operation is in progress. EPlaying An audio le is playing. ERecording An audio le is being recorded. max volume() Returns the maximum volume of the device. set volume(volume) Sets the volume. If the given volume is negative, then the volume is set to zero which mutes the device. If the volume is greater than max volume, then max volume is used. current volume() Returns the current volume set. duration() Returns the duration of the le in microseconds. set position(microseconds) Set the position for the playhead.
2 Descriptions
for these options are based on information found in S60 SDK documentation [4].
48
49
EScheduleFailed ESendFailed This state information is returned when the SMS subsystem has tried to send the message several times in vain. The sms send operation has nalized and subsequent SMS sending is possible. ENoServiceCentre This state information is returned by the SMS subsystem in S60 3.x emulator. In emulator this indicates that the sms send operation has nalized and subsequent SMS sending is possible. EFatalServerError The underlying messaging subsystem in S60 devices might give error messages to the user if the device is not connected to a network while trying to send a message An SMS send failed! note is a common error message. When sending messages in oine-mode or with no network connection these messages are actually added to an outgoing message queue and they might be sent if the device is later on connected to a suitable network4 . This occurs despite the possibly misleading error messages. The current network conditions can be checked e.g. with sysinfo.active profile() and sysinfo.signal bars() invocations. The following is example code for state information processing with sms send operation:
>>> >>> >>> ... ... ... ... ... >>> >>>
import messaging def cb(state): if state==messaging.ESent: print "**Message was sent**" if state==messaging.ESendFailed: print "**Something went wrong - Truly sorry for this**" messaging.sms_send("1234567", "Hello from PyS60!", 7bit, cb) **Message was sent** # This is printed from the callback
50
51
The location module oers APIs to location information related services. Currently, the location has one function: Note: Location module requires capabilities ReadDeviceData, ReadUserData and Location in 3rd Edition devices. gsm location() Retrieves GSM location information: Mobile Country Code, Mobile Network Code, Location Area Code, and Cell ID. A location area normally consists of several base stations. It is the area where the terminal can move without notifying the network about its exact position. mcc and mnc together form a unique identication number of the network into which the phone is logged.
6.5.1 Examples
Here is an example of how to use the location package to fetch the location information:
6.6.1 Example
The following example demonstrates how to use the python position module.
# information about available positioning modules print "***available modules***" print positioning.modules() print "" # id of the default positioning module print "***default module***"
52
print positioning.default_module() print "" # detailed information about the default positioning module print "***detailed module info***" print positioning.module_info(positioning.default_module()) print "" # select a module (however, selecting default module has no # relevance..this has been added just to show the functionality). positioning.select_module(positioning.default_module()) # set requestors. # at least one requestor must be set before requesting the position. # the last requestor must always be service requestor # (whether or not there are other requestors). positioning.set_requestors([{"type":"service", "format":"application", "data":"test_app"}]) # get the position. # note that the first position()-call may take a long time # (because of gps technology). print "***position info***" print positioning.position() print "" # re-get the position. # this call should be much quicker. # ask also course and satellite information. print "***course and satellites***" print positioning.position(course=1,satellites=1) print ""
To run the script in the emulator you must congure PSY emulation (SimPSYCongurator->Select Cong File -><some cong le s>).
53
54
CHAPTER
SEVEN
Data Management
7.1 contacts A contacts related services package
The contacts module oers an API to address book services allowing the creation of contact information databases. The contacts module represents a Symbian contact database as a dictionary-like ContactDb object, which contains Contact objects and which is indexed using the unique IDs of those objects. A Contact object is itself a list-like object, which contains ContactField objects and which is indexed using the eld indices. Unique IDs and eld indices are integers. The ContactDb object supports a limited iter , getitem , delitem , len , subset of dictionary functionality. Therefore, only keys, values, and items are included. ContactDb objects represent a live view into the database. If a contact is changed outside your Python application, the changes are visible immediately, and conversely any changes you commit into the database are visible immediately to other applications. It is possible to lock a contact for editing, which will prevent other applications from modifying the contact for as long as the lock is held. This can be done in, for example, a contacts editor application when a contact is opened for editing, very much like with the Contacts application in your Nokia device. If you try to modify a contact without locking it for editing, the contact is automatically locked before the modication and released immediately afterwards.
find(searchterm) Finds the contacts that contain the given Unicode string as a substring and returns them as a list. import vcards(vcards) Imports the vCard(s) in the given string into the database. export vcards(ids) Converts the contacts corresponding to the IDs in the given tuple ids to vCards and returns them as a string. keys() Returns a list of unique IDs of all Contact objects in the database. compact required() Veries whether compacting is recommended. Returns an integer value indicating either a true or false state. Returns True if more than 32K of space is unused and if this comprises more than 50 percent of the database le, or if more than 256K is wasted in the database le. compact() Compacts the database to its minimum size. delitem (id ) Deletes the given contact from the database. field types() Returns a list of dictionary objects that contains information on all supported eld types. The list contains dictionary objects, which each describe one eld type. The most important keys in the dictionary are type and location which together indentify the eld type. type can have string values such as email address. location can have the string values none, home, or work. Another important key is storagetype, which denes the storage type of the eld. storagetype can have the string values text, datetime, item id, or binary. Note that the Contacts extension does not support adding, reading, or modifying elds of any other type than text or datetime. The other content returned by field types is considered to be advanced knowledge and is not documented here. groups Returns contact groups of the database. Read-only.
rollback() Releases the lock and discards all changes that were made. The contact remains in the state it was before begin. as vcard() Returns the contact as a string in vCard format. add field(type [, value [, label=eld label ][, location=location spec ]]) Adds a new eld into this Contact. This method raises ContactBusy if the contact has been locked by some other application. type can be one of the supported eld types as a string. In Series 60 editions older than the 3rd one the following eld types can be added: city company name country date dtmf string email address extended address fax number first name job title last name mobile number note pager number phone number po box postal address postal code state street address url video number wvid The following eld types are recognized but cannot be created: first name reading last name reading picture speed dial thumbnail image voicetag If 3rd edition of Series 60 is used the following eld types can be added: city company name country date dtmf string email address extended address fax number first name job title 7.1. contacts A contacts related services package 57
last name mobile number note pager number phone number po box postal address postal code state street address url video number picture second name voip sip id personal ringtone share view prefix suffix push to talk locationid indication The following eld types are recognized but cannot be created at present: first name reading last name reading speed dial thumbnail image voice tag wvid All supported eld types are passed as strings or Unicode strings, except for date which is a oat that represents Unix time. For more information on Unix time, see Section 3.5, Date and Time. eld label is the name of the eld shown to the user. If you do not pass a label, the default label for the eld type is used. location spec, if given, must be home or work. Note that not all combinations of type and location are valid. The settings of the current contacts database in use determine which ones are valid. find([type=eld type ][, location=eld location ]) Finds the elds of this contact that match the given search specications. If no parameters are given, all elds are returned. delitem (eldindex ) Deletes the given eld from this contact. Note that since this will change the indices of all elds that appear after this eld in the contact, and since the ContactField objects refer to the elds by index, old ContactField objects that refer to elds after the deleted eld will refer to dierent elds after this operation.
class ContactField ContactField objects have the following attributes: label The user-visible label of this eld. Read-write. value The value of this eld. Read-write. type The type of this eld. Read-only. location The location of this eld. This can be none, work, or home. schema A dictionary that contains some properties of this eld. The contents of this dictionary correspond to those returned by the ContactDb method field types.
class Groups Groups objects have the following attributes: add group([name ]) Creates new contact group and returns corresponding Group object. Group name can be given as an optional parameter.
59
61
of the following: AppointmentEntry, EventEntry, AnniversaryEntry, or TodoEntry. id is the unique ID of the calendar Entry. compact() Compacts the database le. The returned value (integer) indicates the success of compaction; a value other than zero means that the compaction was successful.
62
alarm The alarm datetime value (oat) for the entry. None if alarm is not set. Alternatively removes the alarm if the value is set to None. Alarms can be set to all Entry types. However, only alarms set to Appointments and Anniversaries will actually cause an alarm; this is similar to the Calendar application in your Nokia device, which allows you to set an alarm only for Meetings and Anniversaries. In addition, alarms set to any entries residing in a database other than the default database do not cause actual alarms either. priority The priority of the entry, which can be an integer ranging from 0 to 255. Native Phonebook and Calendar applications in Nokia devices use value 1 for high priority, 2 for normal priority, and 3 for low priority. crossed out The crossed out value of an entry. A value that is interpreted as false means that the entry is not crossed out, whereas a value that is interpreted as true means that the entry is crossed out. Note that TodoEntries must also have a cross-out time while the other entry types cannot have one. If TodoEntry is crossed out using this method, the moment of crossing out is set to the cross-out time of the TodoEntry. See also Section 7.3.3, TodoEntry, cross out time. replication Sets or returns the entrys replication status, which can be one of the following: open, private, or restricted. as vcalendar() Returns this entry as a vCalendar string. AppointmentEntry Objects class AppointmentEntry AppointmentEntry class contains no additional methods compared to the Entry class from which it is derived. EventEntry class EventEntry EventEntry class contains no additional methods compared to the Entry class from which it is derived. AnniversaryEntry class AnniversaryEntry AnniversaryEntry class contains no additional methods compared to the Entry class from which it is derived. TodoEntry TodoEntryobjects represent todo entry types. They have additional properties compared to the Entry class from which they are derived. class TodoEntry TodoEntryobjects have the following additional properties: cross out time The cross-out date value of the entry. The value can be None meaning that the entry is not crossed out, or the cross-out date (oat). The set value must be date (oat). Setting a cross-out time also crosses out the entry. See also Section 7.3.3, Entry Object, crossed out.
63
todo list The ID of the todo list to which this entry belongs. TodoListDict TodoListDict objects are dictionary-like objects that enable accessing todo lists. class TodoListDict TodoListDict objects have the following property: default list The ID of the default todo list. TodoList TodoList objects are dictionary-like objects that enable accessesing todo lists. class TodoList TodoList objects have the following properties: name The name of the todo list as a Unicode string. id Returns the ID of the todo list as an integer.
64
repeat = {"type":"daily", #repeat type "exceptions":[exception_day, exception_day+2*24*60*60], #no appointment on those days "start":appt_start_date, #start of the repeat "end":appt_start_date+30*24*60*60, #end of the repeat "interval":1} #interval (1=every day, 2=every second day etc.) repeat = {"type":"weekly", #repeat type "days":[0,1], #which days in a week (Monday, Tuesday) "exceptions":[exception_day], #no appointment on that day "start":appt_start_date, #start of the repeat "end":appt_start_date+30*24*60*60, #end of the repeat "interval":1} #interval (1=every week, 2=every second week etc.) repeat = {"type":"monthly_by_days", #repeat type # appointments on second Tuesday and last Monday of the month "days":[{"week":1, "day":1},{"week":4, "day":0}], "exceptions":[exception_day], #no appointment on that day "start":appt_start_date, #start of the repeat "end":appt_start_date+30*24*60*60, #end of the repeat "interval":1} #interval (1=every month, 2=every second month etc.) repeat = {"type":"monthly_by_dates", #repeat type "days":[0,15], # appointments on the 1st and 16th day of the month. "exceptions":[exception_day], #no appointment on that day "start":appt_start_date, #start of the repeat "end":appt_start_date+30*24*60*60, #end of the repeat "interval":1} #interval (1=every month, 2=every second month etc.) repeat = {"type":"yearly_by_date", #repeat type "exceptions":[exception_day], #no appointment on that day "start":appt_start_date, #start of the repeat "end":appt_start_date+3*365*24*60*60, #end of the repeat "interval":1} #interval (1=every year, 2=every second year etc.) repeat = {"type":"yearly_by_day", #repeat type # appointments on the second Tuesday of February "days":{"day":1, "week":1, "month":1}, "exceptions":[exception_day], #no appointment on that day "start":appt_start_date, #start of the repeat "end":appt_start_date+3*365*24*60*60, #end of the repeat "interval":1} #interval (1=every year, 2=every second year etc.)
65
All time parameters use Unix time unless stated otherwise. For more information on Unix time, see Section 3.5, Date and Time.
find instances(start date, end date, search str=u [ ,appointments=0,events=0,anniversaries=0,todos=0,remin The parameters for this function include the start date, end date, search string, and optional parameters. The optional parameters dene the entry types to be included into the search. By default all entry types are included. Returns a list that contains Entry instances found in the search. An instance is a dictionary that contains the entry ID and the datetime value. An entry may have several instances if it is repeated, for example once every week, etc. monthly instances(month, appointments=0, events=0, anniversaries=0, todos=0, reminders=0 ) The parameters for this function include month (oat) and optional parameters. The optional parameters dene the entry types to be returned. Returns a list that contains entry instances occurring during the specied calendar month.
66
daily instances(day, appointments=0, events=0, anniversaries=0, todos=0 ) The parameters for this function include day (oat) and optional parameters. The optional parameters dene the entry types to be returned. Returns a list that contains entry instances occurring on the specied day. export vcalendars((int,...)) Returns a vcalendar string that contains the specied entries in vCalendar format. The parameter for this function is a tuple that contains the entry IDs of the exported entries. import vcalendars(string) Imports vcalendar entries, given in the string parameter, to the database. Returns a list that contains the unique IDs of the imported entries. delitem (id ) Deletes the given calendar Entry from the database. id is the unique ID of the calendar Entry. getitem (id ) Returns a calendar Entry object indicated by the unique ID. The returned object can be one of the following: AppointmentEntry, EventEntry, AnniversaryEntry, ReminderEntry, or TodoEntry. id is the unique ID of the calendar Entry.
start time The start datetime value (oat) of the entry or None if the start datetime of the entry is not set. end time The end datetime value (oat) of the entry or None if the end datetime of the entry is not set. id The unique ID of the entry. last modified The datetime value (oat) of the entrys last modication in universal time. originating An integer value indicating if the entry is an originating entry or a modifying entry. alarm The alarm datetime value (oat) for the entry. None if alarm is not set. Alternatively removes the alarm if the value is set to None. Alarms can be set to all Entry types. However, only alarms set to Appointments and Anniversaries will actually cause an alarm; this is similar to the Calendar application in your Nokia device, which allows you to set an alarm only for Meetings and Anniversaries. In addition, alarms set to any entries residing in a database other than the default database do not cause actual alarms either. priority The priority of the entry, which can be an integer ranging from 0 to 255. Native Phonebook and Calendar applications in Nokia devices use value 1 for high priority, 2 for normal priority, and 3 for low priority. crossed out The crossed out value of an entry. Only valid for todo entries. A value that is interpreted as false means that the entry is not crossed out, whereas a value that is interpreted as true means that the entry is crossed out. Note that TodoEntries must also have a cross-out time. If TodoEntry is crossed out using this method, the moment of crossing out is set to the cross-out time of the TodoEntry. See also Section 7.3.3, TodoEntry, cross out time. replication Sets or returns the entrys replication status, which can be one of the following: open, private, or restricted. as vcalendar() Returns this entry as a vCalendar string. AppointmentEntry Objects class AppointmentEntry AppointmentEntry class contains no additional methods compared to the Entry class from which it is derived. EventEntry class EventEntry EventEntry class contains no additional methods compared to the Entry class from which it is derived. AnniversaryEntry class AnniversaryEntry AnniversaryEntry class contains no additional methods compared to the Entry class from which it is derived.
68
ReminderEntry class ReminderEntry ReminderEntry class contains no additional methods compared to the Entry class from which it is derived. TodoEntry TodoEntryobjects represent todo entry types. They have additional properties compared to the Entry class from which they are derived. class TodoEntry TodoEntryobjects have the following additional properties: cross out time The cross-out date value of the entry. The value can be None meaning that the entry is not crossed out, or the cross-out date (oat). The set value must be date (oat). Setting a cross-out time also crosses out the entry. See also Section 7.3.3, Entry Object, crossed out.
repeat = {"type":"daily", #repeat type "exceptions":[exception_day, exception_day+2*24*60*60], #no appointment on those days "start":appt_start_date, #start of the repeat
69
"end":appt_start_date+30*24*60*60, #end of the repeat "interval":1} #interval (1=every day, 2=every second day etc.) repeat = {"type":"weekly", #repeat type "days":[0,1], #which days in a week (Monday, Tuesday) "exceptions":[exception_day], #no appointment on that day "start":appt_start_date, #start of the repeat "end":appt_start_date+30*24*60*60, #end of the repeat "interval":1} #interval (1=every week, 2=every second week etc.) repeat = {"type":"monthly_by_days", #repeat type # appointments on second Tuesday and last Monday of the month "days":[{"week":1, "day":1},{"week":4, "day":0}], "exceptions":[exception_day], #no appointment on that day "start":appt_start_date, #start of the repeat "end":appt_start_date+30*24*60*60, #end of the repeat "interval":1} #interval (1=every month, 2=every second month etc.) repeat = {"type":"monthly_by_dates", #repeat type "days":[0,15], # appointments on the 1st and 16th day of the month. "exceptions":[exception_day], #no appointment on that day "start":appt_start_date, #start of the repeat "end":appt_start_date+30*24*60*60, #end of the repeat "interval":1} #interval (1=every month, 2=every second month etc.) repeat = {"type":"yearly_by_date", #repeat type "exceptions":[exception_day], #no appointment on that day "start":appt_start_date, #start of the repeat "end":appt_start_date+3*365*24*60*60, #end of the repeat "interval":1} #interval (1=every year, 2=every second year etc.) repeat = {"type":"yearly_by_day", #repeat type # appointments on the second Tuesday of February "days":{"day":1, "week":1, "month":1}, "exceptions":[exception_day], #no appointment on that day "start":appt_start_date, #start of the repeat "end":appt_start_date+3*365*24*60*60, #end of the repeat "interval":1} #interval (1=every year, 2=every second year etc.)
70
count line() Returns the number of rows available in the rowset. first line() Positions the cursor on the rst row in the rowset. get line() Gets the current row data for access. is col null(column) Tests whether column is empty. Empty columns can be accessed like normal columns. Empty numerical columns return a 0 or an equivalent value, and text and binary columns have a zero length. next line() Moves the cursor to the next row in the rowset. prepare(db, query) Prepares the view object for evaluating an SQL select statement. db is a Dbms object and query the SQL query to be executed.
int
long oat
yes
72
73
iterkeys iteritems itervalues get setdefault pop popitem clear These work the same way as the corresponding methods in a normal dictionary. In addition, e32dbm objects have the following methods: close() Closes the database. In fast mode, commits all pending updates to disk. close raises an exception if called on a database that is not open. reorganize() Reorganizes the database. Reorganization calls compact on the underlying e32db database le, which reclaims unused space in the le. Reorganizing the database is recommended after several updates. sync() In fast mode, commits all pending updates to disk.
74
CHAPTER
EIGHT
atexit base64 bdb binascii cmd code codecs codeop copy copy reg cStringIO dis errno exceptions future httplib imp keyword linecache marshal math md51 mimetools operator os, os.path
Wraps built-in e32posix. Limitations discussed in Section 3.9, Limitations and Areas of Development.
PY PY Type
(X) X Status
Remarks
75
PY PY PY PY PY PY
X X X X X X
X X X X X X
A minimal implementation: select is supported only for input from sockets. Requires PYD e32socket. Contains extensions as described in Section 8.2.2, socket Module. Limitations discussed in Section 3.9, Limitations and Areas of Development. Wraps built-in sre.
threading PY (X) time built-in X traceback PY X types PY X urllib PY X urlparse(urlsplit only) PY X uu PY X warnings PY X whichdb PY X xreadlines built-in X zipfile PY X zlib PYD X Table 8.1: Status of library module support.
Table 8.1 uses the following coding for module types: PY module is implemented in Python. Built-in module is a built-in C/C++ module. PYD module is a dynamically loadable C/C++ module. For support status, the following codes are used: X included to the Series 60 Python distribution. (X) not included to the Series 60 Python distribution, but works both on phone and SDK. Y included only to the SDK distribution.
76
Note: When listening to a Bluetooth socket on the phone, it is necessary to set the security level. Note: SSL is not supported in S60 1st Edition. SSL client certicates are not supported at all. For examples on the usage of these functions, see Programming with Python for S60 Platform [6]. Setting default Access Point (AP) has been added to the standard socket module. The following related constants and functions are dened: select access point() This opens popup selection where access points are listed and can be selected. Returns selected access point id. access point(apid ) This creates access point object by given apid. Returns access point object. set default access point(apo) This sets the default access point that is used when socket is opened. Setting apo to "None" will clear default access point. access points() This lists access points ids and names that are available. Example 1:
#access point is selected from the list apid = select_access_point() apo = access_point(apid) set_default_access_point(apo) s = socket(AF_INET, SOCK_STREAM) print apo.ip() s.connect((www.sourceforge.net,80)) s.send(GET /\r\n\r\n) s.recv(100) s.close() apo.stop()
Example 2:
#Access point id is already known apo = access_point(1) set_default_access_point(apo) s = socket(AF_INET, SOCK_STREAM) s.connect((www.sourceforge.net,80)) s.send(GET /\r\n\r\n) s.recv(100) s.close() apo.stop()
Example 3:
#display interface ip. #access point is selected from the list apid = select_access_point() apo = access_point(apid) apo.start() #Note that ip-address is given by operator, if static ip-address is not defined, #when connection is started print apo.ip() #When connection is closed dynamic ip-address is released apo.stop()
78
CHAPTER
NINE
The caller of the constructor CSPyInterpreter::NewInterpreterL() may provide its own function aStdioInitFunc for initializing Symbian OS STDLIBs standard I/O descriptors. It gets called with the argument aStdioInitCookie. The CSPyInterpreter class can also be requested to leave STDLIB open at its destruction. The RunScript method establishes a Python interpreter context and runs the script le whose full path name is in argv[0] with the given argument vector. After completion, it leaves the interpreter context and returns a Symbian error code to indicate success or failure. The CSPyInterpreter::PrintError method can be used to print current Python exception information to the standard error output.
int SPyAddGlobal(PyObject *key, PyObject *value) int SPyAddGlobalString(char *key, PyObject *value) PyObject* SPyGetGlobal(PyObject *key) PyObject* SPyGetGlobalString(char *key) void SPyRemoveGlobal(PyObject *key) void SPyRemoveGlobalString(char *key) Dened in python globals.h PyThreadState* PYTHON TLS->thread state Current thread state. Thread state and interpreter lock management must be performed according to the instructions; see [3]. Python for S60 Platform extends the Python/C API by oering a facility for querying the related Python thread state (PYTHON TLS->thread state) from the context of the currently running thread. This can be used to re-establish the interpreter context with PyEval RestoreThread in C/C++ code. To save/restore the interpreter context:
Py_BEGIN_ALLOW_THREADS /* ...your code... */ Py_END_ALLOW_THREADS
Dened in pythread.h int PyThread AtExit(void(*)()) An extenstion to the standard thread modules C API that can be used for registering threadspecic exit functions. In the main thread calling this function has the same eect as calling Py AtExit. For more information, see [1].
80
In addition to the concerns common for all Python C extensions, the following principles should be considered when implementing new Python interfaces in the S60 environment: Maximize the usage of Pythons built-in types at the interfaces. Related to the above: design interfaces in such a way that information can be passed between them with minimal conversions. Convert Symbian operating system exceptions / errors to Python exceptions. Unicode strings are used at the interfaces to represent text that gets shown on the GUI. They can be passed to and from Symbian operating system without conversions. While performing potentially long-lasting / blocking calls from an extension implementation to services outside the interpreter, the interpreter lock must be released and then re-acquired after the call. Rather than always implementing a thin wrapper on top of a Symbian OS facility, consider the actual task for which the script writer needs the particular interface. For example, if the task involves interaction with the users using the GUI, the script writers interest may well be limited to performing the interaction / information exchange in a way that is compatible with the UI style rather than having full control of the low-level details of the GUI implementation. The C/C++ implementation of a Python interface should be optimized for performance and covering access to the necessary features of the underlying Platform. Where necessary, the Python programming interface can be further rened by wrapper modules written in Python. An extension module is packaged in its own dynamically loadable library that must be installed into \system\libs directory and named module name.pyd. The module initialization function must be exported at ordinal 1. The module identication is based on the lename only. As a special feature of PyS60, an optional module nalizer function may be exported at ordinal 2. The macro versions of memory-management functions PyMem MALLOC and PyObject NEW are not included. Use the functions PyMem Malloc and PyObject New instead.
9.2.2 Example
This extension code snippet demonstrates some of the issues mentioned in this chapter, such as: Conversion from Python data types, usage of built-in data types at extension interface, usage of Unicode strings (lines 8-12) Maintenance of the reference counts (line 36) Passing of exceptions between C/C++ code and Python (line 34) Releasing the interpreter lock while performing a blocking call to a service outside the interpreter (lines 29, 31) Simplifying the API to the note facility of the Platform
81
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
extern "C" PyObject * note(PyObject* /*self*/, PyObject *args) { TInt error = KErrNone; int l_tx, l_ty; char *b_tx, *b_ty; if (!PyArg_ParseTuple(args, "u#s#", &b_tx, &l_tx, &b_ty, &l_ty)) return NULL; TPtrC8 stype((TUint8*)b_ty, l_ty); TPtrC note_text((TUint16 *)b_tx, l_tx); CAknResourceNoteDialog* dlg = NULL; if (stype.Compare(KErrorNoteType) == 0) dlg = new CAknErrorNote(ETrue); else if (stype.Compare(KInfoNoteType) == 0) dlg = new CAknInformationNote(ETrue); else if (stype.Compare(KConfNoteType) == 0) dlg = new CAknConfirmationNote(ETrue); else { PyErr_BadArgument(); return NULL; } if (dlg == NULL) return PyErr_NoMemory(); Py_BEGIN_ALLOW_THREADS TRAP(error, dlg->ExecuteLD(note_text)); Py_END_ALLOW_THREADS if (error != KErrNone) return SPyErr_SetFromSymbianOSErr(error); else { Py_INCREF(Py_None); return Py_None; } }
82
CHAPTER
TEN
83
Term Softkey
Denition Softkey is a key that does not have a xed function nor a function label printed on it. On a phone, selection keys reside below or above on the side of the screen, and derive their meaning from what is presently on the screen. Structured Query Language XML-based vector graphics format for describing two-dimensional graphics and graphical applications.
UI UI control WAV
Twips are screen-independent units to ensure that the proportion of screen elements are the same on all display systems. A twip is dened as 1/1440 of an inch, or 1/567 of a centimeter. User Interface UI control is a GUI component that enables user interaction and represents properties or operations of an object. A le format for recording sound, especially in multimedia applications.
84
BIBLIOGRAPHY
[1] G. van Rossum, and F.L. Drake, Jr., editor. [Python] Library Reference. Available at
http://www.python.org/doc
[2] G. van Rossum, and F.L. Drake, Jr., editor. Extending and Embedding [the Python Interpreter]. Available at http://www.python.org/doc [3] G. van Rossum, and F.L. Drake, Jr., editor. Python/C API [Reference Manual]. Available at
http://www.python.org/doc
[4] S60 SDK documentation, available at http://www.forum.nokia.com/ [5] Getting Started with Python for S60 Platform, available at http://www.forum.nokia.com/ [6] Programming with Python for S60 Platform, available at http://www.forum.nokia.com/ [7] Audio & Video section on the Forum Nokia Web site (for Nokia devices),
http://www.forum.nokia.com/audiovideo
[8] Developers section on the S60 Platform Web site (for all S60 devices), http://www.s60.com/ [9] Python for S60 developer discussion board http://discussion.forum.nokia.com/ [10] Scalable Vector Graphics (SVG) 1.1 Specication http://www.w3.org/TR/SVG/
85
86
APPENDIX
Reporting Bugs
In order to improve the quality of Python for S60 the developers would like to know of any deciencies you nd in Python for S60 or its documentation. Before submitting a report, you will be required to log into SourceForge; this will make it possible for the developers to contact you for additional information if needed. It is not possible to submit a bug report anonymously. All bug reports should be submitted via the project PyS60 Bug Tracker on SourceForge (http://sourceforge.net/tracker/?group id=154155). The bug tracker oers a Web form which allows pertinent information to be entered and submitted to the developers. The rst step in ling a report is to determine whether the problem has already been reported. The advantage in doing so, aside from saving the developers time, is that you learn what has been done to x it; it may be that the problem has already been xed for the next release, or additional information is needed (in which case you are welcome to provide it if you can!). To do this, search the bug database using the search box near the bottom of the page. If the problem youre reporting is not already in the bug tracker, go back to the project PyS60 Bug Tracker (http://sourceforge.net/tracker/?group id=154155). Select the Submit a Bug link at the top of the page to open the bug reporting form. The submission form has a number of elds. The only elds that are required are the Summary and Details elds. For the summary, enter a very short description of the problem; less than ten words is good. In the Details eld, describe the problem in detail, including what you expected to happen and what did happen. Be sure to include the version of Python for S60 you used, whether any extension modules were involved and what hardware (the S60 device model or emulator) you were using, including version information of the S60 SDK and your device rmware version as appropriate. You can see the device rmware version by entering *#0000# on the device keypad - please include all information that is shown by this code. The only other eld that you may want to set is the Category eld, which allows you to place the bug report into a broad category (such as Documentation or Library). Each bug report will be assigned to a developer who will determine what needs to be done to correct the problem. You will receive an update each time action is taken on the bug. See Also: How to Report Bugs Eectively
(http://www-mice.cs.ucl.ac.uk/multimedia/software/documentation/ReportingBugs.html)
Article which goes into some detail about how to create a useful bug report. This describes what kind of information is useful and why it is useful. Bug Writing Guidelines
(http://www.mozilla.org/quality/bug-writing-guidelines.html)
Information about writing a good bug report. Some of this is specic to the Mozilla project, but describes general good practices.
87
88
MODULE INDEX
A
appuifw, 13 audio, 47
C
calendar, 60, 65 camera, 33 contacts, 55
E
e32, 9 e32db, 70 e32dbm, 73
G
glcanvas, 44 gles, 38 graphics, 27
I
inbox, 50
K
keycapture, 35
L
location, 51
M
messaging, 49
P
position, 52
S
socket, 77 sysinfo, 11
T
telephone, 49 thread, 77 topwindow, 36
89
90
INDEX
Symbols
delitem () (CalendarDb method), 61, 67 delitem () (ContactDb method), 56 delitem () (Contact method), 58 getitem () (CalendarDb method), 61, 67 getitem () (array method), 38 len () (array method), 38 setitem () (array method), 38
AUTH (data in socket), 77 AUTHOR (data in socket), 77 available fonts() (in module appuifw), 15
B
background color (TopWindow attribute), 37 battery() (in module sysinfo), 11 begin() Contact method, 56 Dbms method, 71 bind() GLCanvas method, 45 Inbox method, 51 Listbox method, 24 Text method, 22 blit() ( method), 32 body (Application attribute), 16 bt advertise service() (in module socket), 77 bt discover() (in module socket), 77 bt obex discover() (in module socket), 77 bt obex receive() (in module socket), 77 bt obex send file() (in module socket), 77 bt rfcomm get available server channel() (in module socket), 77 BTPROTO RFCOMM (data in socket), 77
A
access point() (in module socket), 78 access points() (in module socket), 78 activate tab() (Application method), 18 active profile() (in module sysinfo), 11 add() (Text method), 22 add anniversary() (CalendarDb method), 61, 66 add appointment() (CalendarDb method), 61, 66 add contact() (ContactDb method), 55 add event() (CalendarDb method), 61, 66 add field() (Contact method), 57 add group() (Groups method), 59 add image() (TopWindow method), 36 add reminder() (CalendarDb method), 66 add todo() (CalendarDb method), 61, 66 add todo list() (CalendarDb method), 61 address() (Inbox method), 51 AF BT (data in socket), 77 after() (Ao timer method), 11 alarm (Entry attribute), 63, 68 all keys (data in keycapture), 35 AnniversaryEntry (class in calendar), 63, 68 ao callgate() (in module e32), 9 Ao lock (class in e32), 10 ao sleep() (in module e32), 9 Ao timer (class in e32), 11 ao waittid() (in module thread), 77 ao yield() (in module e32), 9 Application (class in appuifw), 16 AppointmentEntry (class in calendar), 63, 68 appuifw (standard module), 13 arc() ( method), 32 array (class in gles), 38 as vcalendar() (Entry method), 63, 68 as vcard() (Contact method), 57 audio (extension module), 47
C
calendar (extension module), 60, 65 CalendarDb (class in calendar), 61, 66 camera (extension module), 33 cameras available() (in module camera), 33 cancel() (Ao timer method), 11 Canvas (class in appuifw), 25 clear() method, 32 Text method, 22 close() Dbms method, 71 e32dbm method, 74 Sound method, 48 col() (Db view method), 71 col count() (Db view method), 71 col length() (Db view method), 71 col raw() (Db view method), 71 col rawtime() (Db view method), 71 col type() (Db view method), 71 91
color (Text attribute), 21 commit() Contact method, 56 Dbms method, 71 Entry method, 62, 67 compact() CalendarDb method, 62 ContactDb method, 56 Dbms method, 71 compact required() (ContactDb method), 56 Contact (class in contacts), 56 ContactDb (class in contacts), 55 ContactField (class in contacts), 59 contacts (extension module), 55 content() (Inbox method), 51 content (Entry attribute), 62, 67 Content handler (class in appuifw), 24 corner type (TopWindow attribute), 37 count line() (Db view method), 72 create() (Dbms method), 71 cross out time (TodoEntry attribute), 63, 69 crossed out (Entry attribute), 63, 68 current() (Listbox method), 24 current position() (Sound method), 49 current volume() (Sound method), 48
D
daily instances() (CalendarDb method), 61, 67 Db view (class in e32db), 71 Dbms (class in e32db), 71 default list (TodoListDict attribute), 64 default module() (in module position), 52 delete() Inbox method, 51 Text method, 22 dial() (in module telephone), 49 display pixels() (in module sysinfo), 11 display twips() (in module sysinfo), 11 drawNow() (GLCanvas method), 45 drive list() (in module e32), 9 duration() (Sound method), 48
E
e32 (extension module), 9 e32db (extension module), 70 e32dbm (module), 73 EAColumn (data in appuifw), 19 EApplicationWindow (data in appuifw), 18 EBatteryPane (data in appuifw), 19 EBColumn (data in appuifw), 19 ECColumn (data in appuifw), 19 EContextPane (data in appuifw), 18 EControlPane (data in appuifw), 18 EControlPaneBottom (data in appuifw), 19 EControlPaneTop (data in appuifw), 19 ECreated (data in messaging), 49 EDColumn (data in appuifw), 19 EDeleted (data in messaging), 49 92
EDraft (data in inbox), 50 EFatalServerError (data in messaging), 50 EFindPane (data in appuifw), 19 EInbox (data in inbox), 50 EIndicatorPane (data in appuifw), 19 ellipse() ( method), 32 EMainPane (data in appuifw), 18 EMovedToOutBox (data in messaging), 49 ENaviPane (data in appuifw), 19 ENCRYPT (data in socket), 77 end time (Entry attribute), 62, 68 ENoServiceCentre (data in messaging), 50 ENotReady (data in audio), 47 Entry (class in calendar), 62, 67 EOpen (data in audio), 47 EOutbox (data in inbox), 50 EPlaying (data in audio), 47 ERecording (data in audio), 47 EScheduledForSend (data in messaging), 49 EScheduleFailed (data in messaging), 50 EScreen (data in appuifw), 18 ESendFailed (data in messaging), 50 ESent data in inbox, 50 data in messaging, 49 ESignalPane (data in appuifw), 18 EStaconBottom (data in appuifw), 19 EStaconTop (data in appuifw), 19 EStatusPane (data in appuifw), 18 EStatusPaneBottom (data in appuifw), 19 EStatusPaneTop (data in appuifw), 19 ETitlePane (data in appuifw), 18 EUniversalIndicatorPane (data in appuifw), 19 EventEntry (class in calendar), 63, 68 EWallpaperPane (data in appuifw), 19 execute() Dbms method, 71 Form method, 20 exit key handler (Application attribute), 17 export vcalendars() (CalendarDb method), 61, 67 export vcards() (ContactDb method), 56 exposure modes() (in module camera), 33
F
FFormAutoFormEdit (data in appuifw), 20 FFormAutoLabelEdit (data in appuifw), 20 FFormDoubleSpaced (data in appuifw), 20 FFormEditModeOnly (data in appuifw), 20 FFormViewModeOnly (data in appuifw), 20 field types() (ContactDb method), 56 file copy() (in module e32), 9 find() Contact method, 58 ContactDb method, 56 find instances() (CalendarDb method), 61, 66 first line() (Db view method), 72 flags (Form attribute), 20
Index
flash modes() (in module camera), 33 focus Application attribute, 17 Text attribute, 21 font (Text attribute), 21 Form (class in appuifw), 19 format rawtime() (in module e32db), 70 format time() (in module e32db), 70 forwarding (KeyCapturer attribute), 36 free drivespace() (in module sysinfo), 11 free ram() (in module sysinfo), 12 full name() (Application method), 18
G
get() (Text method), 23 get line() (Db view method), 72 get pos() (Text method), 22 get repeat() (Entry method), 62, 67 glBufferData() (in module gles), 42 glBufferDatab() (in module gles), 42 glBufferDataf() (in module gles), 42 glBufferDatas() (in module gles), 42 glBufferDataub() (in module gles), 42 glBufferDataus() (in module gles), 42 glBufferDatax() (in module gles), 42 glBufferSubData() (in module gles), 42 glBufferSubDatab() (in module gles), 42 glBufferSubDataf() (in module gles), 42 glBufferSubDatas() (in module gles), 42 glBufferSubDataub() (in module gles), 42 glBufferSubDataus() (in module gles), 42 glBufferSubDatax() (in module gles), 42 GLCanvas (class in glcanvas), 45 glcanvas (extension module), 44 glClipPlanef() (in module gles), 42 glClipPlanex() (in module gles), 43 glColorPointer() (in module gles), 39 glColorPointerf() (in module gles), 39 glColorPointerub() (in module gles), 39 glColorPointerx() (in module gles), 39 glCompressedTexImage2D() (in module gles), 39 glCompressedTexSubImage2D() (in module gles), 39 glDeleteBuffers() (in module gles), 43 glDeleteTextures() (in module gles), 39 glDrawElements() (in module gles), 39 glDrawElementsub() (in module gles), 39 glDrawElementsus() (in module gles), 39 glDrawTexfvOES() (in module gles), 43 glDrawTexivOES() (in module gles), 43 glDrawTexsvOES() (in module gles), 43 gles (extension module), 38 glFogv() (in module gles), 39 glFogxv() (in module gles), 39 glGenBuffers() (in module gles), 43 glGenTextures() (in module gles), 39 glGetBooleanv() (in module gles), 43 glGetBufferParameteriv() (in module gles), 43
glGetClipPlanef() (in module gles), 43 glGetFixedv() (in module gles), 43 glGetFloatv() (in module gles), 43 glGetIntegerv() (in module gles), 39 glGetLightfv() (in module gles), 43 glGetLightxv() (in module gles), 43 glGetMaterialfv() (in module gles), 43 glGetMaterialxv() (in module gles), 43 glGetString() (in module gles), 39 glGetTexEnvf() (in module gles), 43 glGetTexEnvx() (in module gles), 43 glGetTexParameterf() (in module gles), 43 glGetTexParameterx() (in module gles), 43 glLightfv() (in module gles), 40 glLightModelfv() (in module gles), 39 glLightModelxv() (in module gles), 40 glLightxv() (in module gles), 40 glLoadMatrixf() (in module gles), 40 glLoadMatrixx() (in module gles), 40 glMaterialfv() (in module gles), 40 glMaterialxv() (in module gles), 40 glMatrixIndexPointerOES() (in module gles), 43 glMatrixIndexPointerOESub() (in module gles), 43 glMultMatrixf() (in module gles), 40 glMultMatrixx() (in module gles), 40 glNormalPointer() (in module gles), 40 glNormalPointerb() (in module gles), 40 glNormalPointerf() (in module gles), 40 glNormalPointers() (in module gles), 40 glNormalPointerx() (in module gles), 40 glPointParameterfv() (in module gles), 44 glPointParameterxv() (in module gles), 44 glPointSizePointerOES() (in module gles), 44 glPointSizePointerOESf() (in module gles), 44 glPointSizePointerOESx() (in module gles), 44 glReadPixels() (in module gles), 40 glTexCoordPointer() (in module gles), 40 glTexCoordPointerb() (in module gles), 40 glTexCoordPointerf() (in module gles), 41 glTexCoordPointers() (in module gles), 40 glTexCoordPointerx() (in module gles), 41 glTexEnvfv() (in module gles), 41 glTexEnvxv() (in module gles), 41 glTexImage2D() (in module gles), 41 glTexSubImage2D() (in module gles), 41 glVertexPointer() (in module gles), 41 glVertexPointerb() (in module gles), 41 glVertexPointerf() (in module gles), 41 glVertexPointers() (in module gles), 41 glVertexPointerx() (in module gles), 41 glWeightPointerOES() (in module gles), 44 glWeightPointerOESf() (in module gles), 44 glWeightPointerOESx() (in module gles), 44 graphics (extension module), 27 Group (class in contacts), 59 Groups (class in contacts), 59 groups (ContactDb attribute), 56
Index
93
M
makeCurrent() (GLCanvas method), 45 max ramdrive size() (in module sysinfo), 12 max volume() (Sound method), 48 max zoom() (in module camera), 33 maximum size (TopWindow attribute), 37 measure text() ( method), 32 menu Application attribute, 17 Form attribute, 20 messaging (extension module), 49 mms send() (in module messaging), 49 module info() (in module position), 52 modules() (in module position), 52 monthly instances() (CalendarDb method), 61, 66 multi query() (in module appuifw), 16 multi selection list() (in module appuifw), 16
H
hang up() (in module telephone), 49 hide() (TopWindow method), 36 highlight color (Text attribute), 21 HIGHLIGHT ROUNDED (data in appuifw), 22 HIGHLIGHT SHADOW (data in appuifw), 22 HIGHLIGHT STANDARD (data in appuifw), 22
Icon (class in appuifw), 24 id Contact attribute, 56 Entry attribute, 62, 68 Group attribute, 59 TodoList attribute, 64 Image.inspect() (in module graphics), 27 Image.new() (in module graphics), 27 Image.open() (in module graphics), 27 N image modes() (in module camera), 33 name image sizes() (in module camera), 33 Group attribute, 59 images (TopWindow attribute), 37 TodoList attribute, 64 imei() (in module sysinfo), 11 next line() (Db view method), 72 import vcalendars() (CalendarDb method), 61, note() (in module appuifw), 16 67 import vcards() (ContactDb method), 56 O in emulator() (in module e32), 9 inactivity() (in module e32), 10 OBEX (data in socket), 77 Inbox (class in inbox), 50 open() inbox (extension module), 50 Content handler method, 24 insert() (Form method), 20 Dbms method, 71 is col null() (Db view method), 72 in module calendar, 60, 66 is group (Contact attribute), 56 in module contacts, 55 is ui thread() (in module e32), 10 in module e32dbm, 73 open standalone() (Content handler method), K 24 orientation (Application attribute), 18 keycapture (extension module), 35 originating (Entry attribute), 68 keys() (ContactDb method), 56 os version() (in module sysinfo), 12 keys (KeyCapturer attribute), 35 KMdaRepeatForever (data in audio), 47
L
label (ContactField attribute), 59 last key() (KeyCapturer method), 36 last modified (Entry attribute), 62, 68 layout() (Application method), 18 len() (Text method), 22 length() (Form method), 20 line() ( method), 31 Listbox (class in appuifw), 23 load() (Image method), 28 location ContactField attribute, 59 Entry attribute, 62, 67 extension module, 51
pieslice() ( method), 32 play() (Sound method), 47 point() ( method), 32 polygon() ( method), 31 pop() (Form method), 20 popup menu() (in module appuifw), 16 position() (in module position), 52 position extension module, 52 TopWindow attribute, 37 prepare() (Db view method), 72 priority (Entry attribute), 63, 68 pys60 version (data in e32), 9 pys60 version info (data in e32), 9 PYTHON TLS->thread state, 80 PyThread AtExit(), 80 Index
94
Q
query() (in module appuifw), 15
R
record() (Sound method), 48 rectangle() ( method), 32 release() (in module camera), 35 ReminderEntry (class in calendar), 69 remove image() (TopWindow method), 36 reorganize() (e32dbm method), 74 replication (Entry attribute), 63, 68 reset inactivity() (in module e32), 10 resize() (Image method), 28 RFCOMM (data in socket), 77 ring type() (in module sysinfo), 12 rollback() Contact method, 57 Dbms method, 71 Entry method, 62, 67
S
s60 version info (data in e32), 10 save() (Image method), 28 save hook (Form attribute), 20 say() (in module audio), 47 schema (ContactField attribute), 59 screen (Application attribute), 17 screenshot() (in module graphics), 27 select access point() (in module socket), 78 select module() (in module position), 52 selection list() (in module appuifw), 16 set() (Text method), 23 set default access point() (in module socket), 78 set exit() (Application method), 18 set home time() (in module e32), 9 set list() (Listbox method), 24 set pos() (Text method), 23 set position() (Sound method), 48 set repeat() (Entry method), 62, 67 set requestors() (in module position), 52 set security() (in module socket), 77 set tabs() (Application method), 18 set time() (Entry method), 62, 67 set volume() (Sound method), 48 shadow (TopWindow attribute), 37 show() (TopWindow method), 36 signal() (Ao lock method), 11 signal bars() (in module sysinfo), 12 signal dbm() (in module sysinfo), 12 size Canvas attribute, 27 Image attribute, 29 TopWindow attribute, 37 sms messages() (Inbox method), 51 sms send() (in module messaging), 49 socket (extension module), 77 Sound (class in audio), 47 Index
Sound.open() (in module audio), 47 SPyAddGlobal(), 80 SPyAddGlobalString(), 80 SPyErr SetFromSymbianOSErr(), 79 SPyGetGlobal(), 80 SPyGetGlobalString(), 80 SPyRemoveGlobal(), 80 SPyRemoveGlobalString(), 80 start() (KeyCapturer method), 36 start exe() (in module e32), 10 start finder() (in module camera), 35 start server() (in module e32), 10 start time (Entry attribute), 62, 68 state() (Sound method), 48 stop() Image method, 29 KeyCapturer method, 36 Sound method, 48 stop finder() (in module camera), 35 style (Text attribute), 21 STYLE BOLD (data in appuifw), 22 STYLE ITALIC (data in appuifw), 22 STYLE STRIKETHROUGH (data in appuifw), 22 STYLE UNDERLINE (data in appuifw), 22 sw version() (in module sysinfo), 12 sync() (e32dbm method), 74 sysinfo (extension module), 11
T
take photo() (in module camera), 33 telephone (extension module), 49 text() ( method), 32 thread (extension module), 77 time() (Inbox method), 51 title Application attribute, 17 Contact attribute, 56 todo list (TodoEntry attribute), 64 todo lists (CalendarDb attribute), 61 TodoEntry (class in calendar), 63, 69 TodoList (class in calendar), 64 TodoListDict (class in calendar), 64 TopWindow (class in topwindow), 36 topwindow (extension module), 36 total ram() (in module sysinfo), 12 total rom() (in module sysinfo), 12 transpose() (Image method), 28 type (ContactField attribute), 59
U
uid() (Application method), 18 unread() (Inbox method), 51
V
value (ContactField attribute), 59 visible (TopWindow attribute), 37
95
W
wait() (Ao lock method), 10 white balance modes() (in module camera), 33
96
Index