首 页 | 新 闻 | Symbian | Android| Windows Mobile | J2ME | 下载中心 | 游戏策划招聘与求职 | 购书指南 | 视频教程
您现在的位置: 开发视界 >> Symbian >> 用户界面 >> 正文
S60 Python 编程指南——文本输入练习(一)
作者:佚名    文章来源:转载    更新时间:2006-12-19 11:48:04

按照以下说明编写一个程序:

  1. 在屏幕上显示一个文本输入框。输入框上的需要有“Type a word”字样的提示。
  2. 在用户在文本输入框输入完文字并按下”OK”后,用一个弹出框显示用户输入的文本信息。

input field   popup note

示例代码:
-------------------------------------
# Copyright (c) 2005 Jurgen Scheible
# This script performs a query with a single-field dialog (text input field)
# and displays the users input as a pop-up note
import appuifw
data = appuifw.query(u"Type a word:", "text")
appuifw.note(u"The typed word was: " + data, "info")
# NOTE: a text string must be defined as unicode
# u"..."
# The mobile can not diplay the text otherwise properly!
-------------------------------------
代码说明:
-------------------------------------
# Copyright (c) 2005 Jurgen Scheible
# This script performs a query with a single-field dialog (text input field)
# and displays the users input as a pop-up note
# 1. import the application user interface framework module
import appuifw

# 2. , 3. create a text input field:  appuifw.query(label, type) and variable
data = appuifw.query(u"Type a word:", "text")

# 4. create a pop-up note: appuifw.note(label, type)
appuifw.note(u"The typed word was: " + data, "info")
""" detailed description:

1. we import the "appuifw" module to handle UI widgets like text input fields and
   pop-up notes etc.
2. we create a single-field dialog (text input field) using the .query() function
   of the appuifw module.
   we include in the brackets 2 parameters:
   - label: as label we put the text u"Type a word:" (the u must be there because
            the phone understands only text declared as unicode, the high commas
            must be there because label must be given as a string)
   - type: as type we put "text". It declares the input field as text type
           (other possible types: "number", "date", "time", "query", "code")
   -> separate the the two parameters with a comma.
3. We create a variable called data, and by putting data = appui... we write
   the result of the text input field into this variable
   (after user has typed something when he/she runs the script)

4. We create a pop-up note using the .note() function of the appuifw module.
    we include in the brackets the 2 parameters:
   - label: as label we put the text u"The typed word was: " + data
            This is the text that will appear in the pop-up note. Again the text
            must be given as a string in highcommas.
            But our pop-up note shall also inculde the result that the user
            has typed in, therefore we add the content of our variable data to our label
            string by writing + data (adding the content of a variable to a string)           
   - type: as type we put "info". It declares the pop-up note as info. This puts
           an exclamationmark in the pop-up note (other possible types: "error","conf")
   -> again, separate the the two parameters with a comma.

"""

相关文章:
S60 Python 编程指南——程序菜单练习(2)
S60 Python 编程指南——弹出列表
S60 Python 编程指南——对话框和通知信息
S60 Python 编程指南——定义函数
S60 Python 编程指南——发送短信给多个手机
MIME的一些知识
symbain OS编码特定规则
资源文件中分号结尾的判断
 

站点地图 | 加入收藏 | 联系站长 | 广告服务 |
QQ:280529124  Tel:0592-8271361 辽ICP备05021703号