Custom Search

Sunday, January 3, 2010

PyS60 Tutorial - Forms

PyS60 Tutorial - Forms

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

import appuifw, e32

#Define the exit function

def quit():

app_lock.signal()

appuifw.app.exit_key_handler=quit

#Create a list to be used in 'combo' selection mode

model=[u'6630', u'E90', u'7610', u'N95', u'N73']

#Define the field list (consists of tuples: (label, type ,value)); label is a unicode string

#Type is one of the following strings: 'text', 'number', 'date', 'time',or 'combo'

data=[(u'Mobile','text', u'Nokia'),(u'Model','combo', (model,0)),(u'Amount','number', 5),(u'Date','date'),(u'Time','time')]

#Set the view/edit mode of the form

flags=appuifw.FFormEditModeOnly

#Create an instance of the form

f=appuifw.Form(data, flags)

#Make the form visible on the UI

f.execute()

app_lock=e32.Ao_lock()

app_lock.wait()

/************ Complete Source Code End *************/

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

import appuifw, e32

#Define the exit function

def quit():

app_lock.signal()

appuifw.app.exit_key_handler=quit

# Create a list to be used in 'combo' selection mode

# Create a list 'model' to used in 'combo' as values

model=[u'6630', u'E90', u'7610', u'N95', u'N73']

# Define the field list 'data' (consists of tuples: (label, type ,value)); label is a unicode string

# Type is one of the following strings: 'text', 'number', 'date', 'time',or 'combo', value is the value

# to be displayed in the corresponding field,

# 'text' -------> text field

# 'number' -------> number field

# 'date' -------> date field

# 'time' -------> time field

# 'combo' -------> combo box

data=[(u'Mobile','text', u'Nokia'),(u'Model','combo', (model,0)),(u'Amount','number', 5),(u'Date','date'),(u'Time','time')]

# Set the view/edit mode of the form

# Here setting the attribute 'flags' to Ediit mode only for Form type object.

# We can use any name for 'flags'. 'flags' is a default argument to Form, see syntax of form.

# This flag is defined in the module appuifw, So we can directly access it using module name.

flags=appuifw.FFormEditModeOnly

# Create an instance or object of the Form Type

# Passing field list 'data' and flag 'flags' as argument

f = appuifw.Form(data, flags)

# Make the form (form object) visible on the UI

f.execute()

app_lock=e32.Ao_lock()

app_lock.wait()

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

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

----------------------------------------------------------

Form implements a dynamically configurable, editable multi-field dialog. Form caters for advanced dialog use cases with

requirements such as free selectability of the combination of fields, possibility of validating the user input, and automatically

producing the contents of some dialog fields before allowing the closing of the dialog.

Form([fields=field_list, flags=flag])

For creates a Form instance (object).

# field_list consists of tuples: (label, type [,value]), where

# label is a Unicode string

# type is one of the following strings: 'text', 'number', 'date', 'time',or 'combo'

# value, depending on type: Unicode string, numeric, float (seconds since Unix epoch rounded down to the nearest local midnight),

float (seconds since local midnight), or ([unicode_string choices], index)

Form can also be configured and populated after construction. The configuration flags are visible as an attribute. Form implements

the list protocol that can be used for setting the form fields, as well as obtaining their values after the dialog has been executed.

----------------------------------------------------------

Some of the attributes of the Form instance or object

This 'flags' attribute of Form Type object holds the values of the various configuration flags. Currently supported flags are:

FFormEditModeOnly

When this flag is set, the form remains in edit mode while execute runs.

This flag is defined in the module appuifw, So we can directly access it using module name.

----------------------------------------------------------

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

No comments:

Post a Comment