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

Snippets has posted 5883 posts at DZone. View Full User Profile

Popup Dialog For Phonebook Number

  • submit to reddit
        A minimal example to let you choose from you mobile phonebook.
import contacts, appuifw
db =
names = []
numbers = []
for i in db:
  num = db[i].find('mobile_number')
  if num:
    numbers.append(num[0].value) # first mobile

i = appuifw.selection_list(names)
print 'number =', numbers[i]


Snippets Manager replied on Wed, 2006/09/06 - 7:52pm

In order to make a list of cell phones ONLY (useful when developping some SMS application), it is necessary to move only ONE line of code: names.append(db[i].title) into the IF cycle, and remove the else statement, so the code is shorter: import contacts, appuifw db = 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]