Here is an implementation that uses appuifw.Form I recently posted on the forum:
# Copyright (c) 2006-2007 LEFEVRE Damien
# appuifw.Form implementation example
import appuifw
## Simple MyFormView class to demonstrate the use of forms.
class MyFormView( object ):
## The constructor.
def __init__( self ):
## Bool
self._iIsSaved = False
## Model list.
self._iModels = [u'6600', u'6630', u'7610', u'N90', u'N70']
## Form fields.
self._iFields = [( u'Mobile', 'text', u'Nokia'),
( u'Model', 'combo', ( self._iModels, 0 ) ),
( u'Amount','number', 5 ),
( u'Date','date' ),
( u'Time','time' )]
## Displays the form.
def setActive( self ):
self._iIsSaved = False
self._iForm = appuifw.Form(self._iFields, appuifw.FFormEditModeOnly)
self._iForm.save_hook = self._markSaved
self._iForm.flags = appuifw.FFormEditModeOnly
self._iForm.execute( )
## save_hook send True if the form has been saved.
def _markSaved( self, aBool ):
self._iIsSaved = aBool
## _iIsSaved getter.
def isSaved( self ):
return self._iIsSaved
# here you can put for example all the getters you need:
#---------------------------------------------------------
## Return mobile field value.
def getMobile( self ):
return self._iForm[0][2].encode( "utf-8" )
## Return model field value..
def getModel( self ):
## This would return the index
#return self._iForm[1][2][1]
## This returns the model
return self._iModels[self._iForm[1][2][1]].encode( "utf-8" )
## Return amount field value.
def getAmount( self ):
return self._iForm[2][2]
## Return date field value.
def getDate( self ):
return self._iForm[3][2]
## Return time field value.
def getTime( self ):
return self._iForm[4][2]
if __name__ == "__main__":
appuifw.app.title = u'Try Forms'
myForm = MyFormView( )
myForm.setActive( )
if myForm.isSaved( ):
print myForm.getMobile( )
print myForm.getModel( )
print myForm.getAmount( )
print myForm.getDate( )
print myForm.getTime( )