信息:多重疑问,选择列表,多项选择列表 所有示例文件UI功能都由模块 appuifw_overview.py 提供 appuifw_overview.py 代码如下:
# Copyright (c) 2006 Jurgen Scheible
# Script that creates a application menue to select all possible
# appuifw functions to see how they appear
import appuifw
import e32
# define the functions:
# note (3 different types are possible)
def note_info(): # type: info
# create a pop-up note: appuifw.note(label, type)
appuifw.note(u"Hello", "info")
def note_error(): # type: error
appuifw.note(u"file not found", "error")
def note_conf(): # type: conf
appuifw.note(u"upload done", "conf")
# query
def query_text():
# create a single-field dialog (text input field): appuifw.query(label, type)
data = appuifw.query(u"Type a word:", "text")
print data
def query_number():
# create a single-field dialog (number input field): appuifw.query(label, type)
data = appuifw.query(u"Type a number:", "number")
print data
def query_date():
# create a single-field dialog (date input field): appuifw.query(label, type)
data = appuifw.query(u"Type a date:", "date")
print data
def query_time():
# create a single-field dialog (time input field): appuifw.query(label, type)
data = appuifw.query(u"Type a time:", "time")
print data
def query_code():
# create a single-field dialog (code input field): appuifw.query(label, type)
data = appuifw.query(u"Type a code:", "code")
print data
def query_question():
# create a single-field dialog (question): appuifw.query(label, type)
if appuifw.query(u"Are you ok:", "query") == True:
print "you pressed ok"
else:
print "you pressed cancel"
# multi_query
def multi_query():
# create a double-field dialog (text input field): appuifw.multi_query(label1, label2)
data1,data2 = appuifw.multi_query(u"Type your first name:",u"Type your surname:")
print data1
print data2
# popup_menu
def popup_menu():
# create a list as content for the menu
L = [u"Stefan", u"Holger", u"Emil"]
# create the popup menu: appuifw.popup_menu(list, label)
test = appuifw.popup_menu(L, u"Select + press OK:")
if test == 0 : # 0 refers to the first entry in the list L
print "Stefan was selected"
if test == 1 : # 1 refers to the second entry in the list L
print "Holger was selected"
if test == 2 : # 2 refers to the third entry in the list L
print "Emil was selected"
# selection_list
def selection_list():
# define the list of items
L = [u'cakewalk', u'com-port', u'computer', u'bluetooth', u'mobile', u'screen', u'camera', u'keys']
# create the selection list: appuifw.selection_list(list , search_field=1 or 0)
index = appuifw.selection_list(L , search_field=1)
# use the result of the selection to trigger some action (here we just print something)
if index == 0:
print "cakewalk was selected"
else:
print "thanks for choosing"
# - multi_selectionlist: with checkbox
def multi_selectionlist_checkbox():
# define the list of items
L = [u'cakewalk', u'com-port', u'computer', u'bluetooth', u'mobile', u'screen', u'camera', u'keys']
# create the multi-selection list with checkbox
index = appuifw.multi_selection_list(L , style='checkbox', search_field=1)
# - multi_selectionlist: with checkmark
def multi_selectionlist_checkmark():
# define the list of items
L = [u'cakewalk', u'com-port', u'computer', u'bluetooth', u'mobile', u'screen', u'camera', u'keys']
# create the multi-selection list with checkmark
tuple = appuifw.multi_selection_list(L , style='checkmark', search_field=1)
# define an exit key handler
def exit_handler():
lock.signal() # .signal releases the Active Object
# set an Active Object (needs to be done for application menus)
lock=e32.Ao_lock()
# create the application menu
appuifw.app.menu=[
(u'multi_query',multi_query),
(u'popup-menu',popup_menu),
(u'selection_list',selection_list),
(u'checkbox: multi_list',multi_selectionlist_checkbox),
(u'checkmark: multi_list',multi_selectionlist_checkmark),
(u'Exit',lock.signal),
(u'note info',note_info),
(u'note error',note_error),
(u'note conf',note_conf),
(u'query text',query_text),
(u'query number',query_number),
(u'query date',query_date),
(u'query time',query_time),
(u'query code',query_code),
(u'query query',query_question)]
appuifw.app.body = appuifw.Text(u'press options')
# define what shall happen it the exit button is pressed
appuifw.app.exit_key_handler=exit_handler
lock.wait()
多重请求: appuifw.multi_query(label1,label2)multi_query 函数创建 2 个对话框(2个输入区),如右边的屏幕截图。 - import appuifw
- data1,data2 = appuifw.multi_query(u"Type your first name:",u"Type your surname:")
- print data1
- print data2
示例代码:
# Copyright (c) 2005 Jurgen Scheible
# This script creates 2 text input fields on one screen
# It uses the multi_query function of the appuifw module
# import the application user interface framework module
import appuifw
# create 2 text input fields at the same time: appuifw.multi_query(label1, label2)
data1,data2 = appuifw.multi_query(u"Type your first name:",u"Type your surname:")
# print the reuslts on the screen
print data1
print data2

选择列表:appuifw.selection_list(choices=list,search_field=1)
- import appuifw
- # define the list of items (put a u in front - items must be written in unicode!)
- L = [u'cakewalk', u'com-port', u'computer', u'bluetooth', u'mobile', u'screen', u'keys']
- # create the selection list
- index = appuifw.selection_list(choices=L , search_field=1)
- # use the result of the selection to trigger some action (here we just print something)
- if index == 0:
- print "cakewalk was selected"
- else:
- print "thanks for choosing"
 注意: search_field=1 可以在列表末尾显示一个搜索框。 search_field=0 则反之。 示例代码:
# Copyright (c) 2005 Jurgen Scheible
# This script executes a dialog that allows the users to select
# an item in a list and returns the index (of the list) of the chosen item
# It uses the .selection_list() function of the appuifw module
# appuifw.selection_list(choices=list , search_field=0 or 1)
# import the application user interface framework module
import appuifw
# define the list of items (items must written in unicode! -> put a u in front)
L = [u'cakewalk', u'com-port', u'computer', u'bluetooth', u'mobile', u'screen', u'camera', u'keys']
# create the selection list
index = appuifw.selection_list(choices=L , search_field=1)
# use the result of the selection to trigger some action (here we just print something)
if index == 0:
print "cakewalk was selected"
else:
print "thanks for choosing"
# the search_field=1 (set to 1) enables a search functionality for looking
# up items in the list. IMPORTANT: to activate the find pane
# (search functionality) you need to press a keyboard key when the script
# is executed and the list has appeared on the screen.
# if search_field=0 no search functionality is enabled. 复选列表 两种不同样式: 1、使用复选框: appuifw.multi_selection_list(list , style=’checkbox’, search_field=1) 2、使用标记: appuifw.multi_selection_list(L , style=’checkmark’, search_field=1) 使用复选框 - # define the list of items (items must written in unicode! -> put a u in front)
- L = [u'cakewalk', u'com-port', u'computer', u'bluetooth', u'mobile', u'screen', u'keys']
- # create the multi-selection list with checkbox
- index = appuifw.multi_selection_list(L , style='checkbox', search_field=1)
示例代码:
# Copyright (c) 2005 Jurgen Scheible
# This script executes a dialog that allows the users to make multiple selections
# of items in a list via checkbox. It returns the indexes (of the list) of the chosen items
# It uses the .multi_selection_list() function of the appuifw module
# appuifw.multi_selection_list(choices=list , style='checkbox', search_field=1)
# import the application user interface framework module
import appuifw
# define the list of items (items must written in unicode! -> put a u in front)
L = [u'cakewalk', u'com-port', u'computer', u'bluetooth', u'mobile', u'screen', u'camera', u'keys']
# create the multi-selection list
index = appuifw.multi_selection_list(L , style='checkbox', search_field=1)
# create a new list (Lnew) that inlcudes only the selected items and print the new list (Lnew)
Lnew = index
print Lnew
 使用标记 - import appuifw
- # define the list of items (items must written in unicode! -> put a u in front)
- L = [u'cakewalk', u'com-port', u'computer', u'bluetooth', u'mobile', u'screen', u'keys']
- # create the multi-selection list with checkmark
- tuple = appuifw.multi_selection_list(L , style='checkmark', search_field=1)
示例代码:
# Copyright (c) 2005 Jurgen Scheible
# This script executes a dialog that allows the users to make multiple selections
# of items in a list and returns the indexes (of the list) of the chosen items
# It uses the .multi_selection_list() function of the appuifw module
# appuifw.multi_selection_list(choices=list , style='checkmark', search_field=0 or 1)
# import the application user interface framework module
import appuifw
# define the list of items (items must written in unicode! -> put a u in front)
L = [u'cakewalk', u'com-port', u'computer', u'bluetooth', u'mobile', u'screen', u'camera', u'keys']
# create the multi-selection list
tuple = appuifw.multi_selection_list(L , style='checkmark', search_field=1)
# create a new list (Lnew) that inlcudes only the selected items and print the new list (Lnew)
Lnew = tuple
print Lnew
print tuple
# Note: if you set the style parameter to style='checkmark' like here, then you can put
# a mark behind the items by pressing the EDIT key once you have navigated to an item to
# make your selection.
# the search_field=1 (set to 1) enables a search functionality for looking
# up items in the list (applies only when style='checkmark').
# IMPORTANT: to activate the find pane
# (search functionality) you need to press a keyboard key when the script
# is executed and the list has appeared on the screen.
# if search_field=0 no search functionality is enabled.
 |