| ID | Creation date | July 9, 2007 | |
| Platform | S60 1st Edition, S60 2nd Edition, S60 3rd Edition | Tested on devices | Nokia N95, Nokia E90 |
| Category | Python | Subcategory | UI |
| Keywords (APIs, classes, methods, functions): appuifw |
This article explains how to use the Listbox class of the appuifw module in Python.
The icons can be taken from either an MIF file (from S60 2nd Edition FP3 onwards) or an MBM file.
In S60 1st Edition and S60 2nd Edition the path of the MBM file containing data for the icons is z:\\system\\data\\avkon.mbm. In S60 3rd Edition the path of the MIF file containing data for the icons is z:\\resource\\apps\\avkon2.mif and information about the indexes for various icons can be found in the avkon.mbg file located in \Epoc32\include.
import appuifw, e32
app_lock = e32.Ao_lock()
#Define the exit function
def quit():
app_lock.signal()
appuifw.app.exit_key_handler = quit
#Create a list of items to be displayed (Unicode strings)
items = [u"Item 1", u"Item 2", u"Item 3"]
#Create an instance of Listbox and set it as the application's body
lb = appuifw.Listbox(items, lambda:None)
appuifw.app.body = lb
#Wait for the user to request the exit
app_lock.wait()
import appuifw, e32
app_lock = e32.Ao_lock()
#Define the exit function
def quit():
app_lock.signal()
appuifw.app.exit_key_handler = quit
#Define the icons to be used
icon1 = appuifw.Icon(u"z:\\resource\\apps\\avkon2.mif", 16412, 16413)
icon2 = appuifw.Icon(u"z:\\resource\\apps\\avkon2.mif", 16424, 16425)
#Create a list of items to be displayed
#An item consists of two fields (Unicode strings) and an icon
items = [(u"Signal", u"Strong", icon1), (u"Battery", u"Full", icon2)]
#Define a function that is called when an item is selected
def handle_selection():
appuifw.note(items[lb.current()][0] + u" has been selected.", 'info')
#Create an instance of Listbox and set it as the application's body
lb = appuifw.Listbox(items, handle_selection)
appuifw.app.body = lb
#Wait for the user to request the exit
app_lock.wait()
The listbox is created and displayed.
Instances of Listbox have the following attributes:
Read only. A tuple containing the width and height of the listbox. Available starting with S60 3rd Edition.
Read only. A tuple containing the coordinates of the top left corner of the listbox. Available starting with S60 3rd Edition.
Instances of Listbox have the following methods:
Binds the callable Python object callback to event event_code.
Returns the index of the currently selected item.
Sets the contents of the listbox to list, which is a list of Unicode strings or a list of tuples. current is the index of the focused item.
No related wiki articles found