import e32, appuifw
 
def __exit__( ):
 APP_LOCK.signal( )
 
def doSave( ):
 try:
 f = open( 'c:\\yourFile.txt', 'wb' )
 yourText = appuifw.app.body.get( )
 f.write( yourText.encode("utf-8") )
 f.close
 appuifw.note( u'Saved :)', 'conf' )
 
 except IOError, e:
 appuifw.note( u'Wrong file path!', 'error' )
 
 except UnicodeError, e:
 appuifw.note( unicode( e ), 'error' )
 
 
if __name__ == "__main__":
 APP_LOCK = e32.Ao_lock( )
 appuifw.app.title = u'Text to file'
 appuifw.app.exit_key_handler = __exit__
 appuifw.app.body = appuifw.Text()
 appuifw.app.menu = [( u'Save', doSave ),
 ( u'Exit', __exit__ )]
 APP_LOCK.wait( )