DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Popup Dialog For Phonebook Number
A minimal example to let you choose from you mobile phonebook.
import contacts, appuifw
db = contacts.open()
names = []
numbers = []
for i in db:
names.append(db[i].title)
num = db[i].find('mobile_number')
if num:
numbers.append(num[0].value) # first mobile
else:
numbers.append(None)
i = appuifw.selection_list(names)
print 'number =', numbers[i]






Comments
Snippets Manager replied on Wed, 2006/09/06 - 7:52pm
names.append(db[i].title)into the IF cycle, and remove the else statement, so the code is shorter:import contacts, appuifw db = contacts.open() names = [] numbers = [] for i in db: num = db[i].find('mobile_number') if num: names.append(db[i].title) numbers.append(num[0].value) # first mobile i = appuifw.selection_list(names) print 'number =', numbers[i]