
Originally Posted by
Rafael T.
Although you can know the selected item using popup menu too.
Example:
Code:
import appuifw
choices = [u"Symbian",u"PyS60",u"MobileArt"]
index = appuifw.popup_menu(choices,u"Select:")
if index != None:
appuifw.note(choices[index])
And remember, Python is very powerful manipulator of lists. You can construct a single list containing all the choices and "answers":
Code:
choices = [
(u"Symbian", u"Symbian,aha"),
(u"PyS60", u"PyS60-yeah"),
(u"MobileArt", u"IloveMobileArt"),
]
index = appuifw.popup_menu([a[0] for a in choices],
u"Select:")
if index != None:
appuifw.note(choices[index][1])
And of course you can use callable functions too:
Code:
def handle_symbian_stuff():
appuifw.note(u"Symbian,aha")
choices = [
(u"Symbian", handle_symbian_stuff),
# [...]
]
index = appuifw.popup_menu([a[0] for a in choices],
u"Select:")
if index != None:
choices[index][1]() # This calls function handle_symbian_stuff
# If user selected "Symbian" from popup_menu