You Are Here:

Community: Developer Discussion Boards

#1 Old Listbox - append()!!! - 2009-04-27, 09:21

Join Date: Feb 2009
Posts: 72
v divya
Offline
Regular Contributor
Hi all,

I now have a query regarding Listbox... I have appended some items into the listbox using append()..

I have used this append() inside another fn add().. But when I print the current item it is always printing the first item in the list..

Y is it like this.. Can someone provide soln for this....
Reply With Quote

#2 Old Re: Listbox - append()!!! - 2009-04-27, 11:58

Join Date: Feb 2009
Posts: 72
v divya
Offline
Regular Contributor
Hi again,

I have added my code here.. The code might not sound professional so kindly bear with it...

Code:
import appuifw
import e32

app_lock = e32.Ao_lock()
def quit():
    app_lock.signal()
    appuifw.app.exit_key_handler = quit

def menu():
    global saved
    lb=main()
    fields = [(u"Name",'text',u'')]
    flags = appuifw.FFormEditModeOnly
    saved = False
    def save(arg):
        global saved
        saved = True
        return True
    form = appuifw.Form(fields,flags)
    form.save_hook= save
    form.execute()
    
    if saved == True:
        add = form[0][2]
        DynList.append(add)
    lb = main()
                 
appuifw.app.menu = [(u"Add",menu),(u"Exit",quit)]

DynList = [(u"John")]

def Handle_Selection():
    lb = main()
    appuifw.note(u"Welcome " + DynList[lb.current()])

def main():
    lb = appuifw.Listbox(DynList,Handle_Selection)
    appuifw.app.body = lb
    return lb

main()

app_lock.wait()
When I click on any item in the list (even after adding some items in the list) it always gives "Welcome John"
I am not able to get the current listbox item at all...

What change to make in this sample code to get the current item displayed...
Reply With Quote

#3 Old Re: Listbox - append()!!! - 2009-04-27, 14:17

Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
bogdan.galiceanu's Avatar
bogdan.galiceanu
Online
Forum Nokia Champion
I wasn't able to find the exact problem with that code but it works if you make it less complicated by not making the main function return the Listbox instance:
Code:
import appuifw
import e32

app_lock = e32.Ao_lock()
def quit():
    app_lock.signal()
appuifw.app.exit_key_handler = quit

def menu():
    global saved
    fields = [(u"Name",'text',u'')]
    flags = appuifw.FFormEditModeOnly
    saved = False
    def save(arg):
        global saved
        saved = True
        return True
    form = appuifw.Form(fields,flags)
    form.save_hook= save
    form.execute()
    
    if saved == True:
        add = form[0][2]
        DynList.append(add)
    main()
                 
appuifw.app.menu = [(u"Add",menu),(u"Exit",quit)]

def Handle_Selection():
    appuifw.note(u"Welcome " + DynList[lb.current()])

DynList = [(u"John")]

def main():
    global lb
    lb = appuifw.Listbox(DynList,Handle_Selection)
    appuifw.app.body = lb

main()

app_lock.wait()
By the way, you can use the Listbox.set_list(list) method to simply update the entries in the Listbox instead of creating it every time.
Last edited by bogdan.galiceanu : 2009-04-27 at 14:32. Reason: Added version with "main" function
Reply With Quote

#4 Old Re: Listbox - append()!!! - 2009-04-27, 16:36

Join Date: Feb 2009
Posts: 72
v divya
Offline
Regular Contributor
Thank u very much bogdan.. But still I would be happy if I get a soln when called from inside a function.. I am using that sort of coding.....
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
how to display the Listbox arungupta_2jan General Symbian C++ 4 2009-03-03 22:10
problem in ListBox aditighosal General Symbian C++ 8 2008-07-16 21:01
Listbox... harsh_vs Symbian User Interface 2 2008-02-15 21:29
Full screen listbox skin not rendered correctly template60 General Symbian C++ 2 2007-09-11 05:34
ListBox Errors javadi82 Symbian User Interface 7 2006-11-08 14:29

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d81449X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZpythonQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZuserE5ftagQSxpythonX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ