一、按照以下说明编写一个程序: - 在屏幕上显示一个文本输入框。输入框上的需要有“Type a word”字样的提示。
- 在用户在文本输入框输入完文字并按下”OK”后,用一个弹出框显示用户输入的文本信息。
示例代码: ------------------------------------- # 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.
""" 二、按照以下说明编写一个程序: - 在屏幕上显示一个文本输入框。输入框上的需要有“Type your first name”字样的提示。
- 在用户在文本输入框输入完文字并按下”OK”后,用一个弹出框显示用户输入的文本信息: Your first name is: < 用户的输入>。
- 在屏幕上显示一个文本输入框。输入框上的需要有“Type your surname”字样的提示。
- 在用户在文本输入框输入完文字并按下”OK”后,用一个弹出框显示用户输入的文本信息: Your surname is: < 用户的输入>。
- 用弹出框显示一个通知消息: Your full name is: < 用户的输入>。
示例代码: ------------------------------------ # Copyright (c) 2005 Jurgen Scheible import appuifw data1 = appuifw.query(u"Type your first name:", "text") appuifw.note(u"Your first name is: " + data1, "info") data2 = appuifw.query(u"Type your surname:", "text") appuifw.note(u"Your surname is: " + data2, "info") appuifw.note(u"Your full name is: " + data1 +u" " + data2, "info") ----------------------------------- |