×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    72

    Listbox - append()!!!

    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....

  2. #2
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    72

    Re: Listbox - append()!!!

    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...

  3. #3
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Listbox - append()!!!

    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 13:32. Reason: Added version with "main" function

  4. #4
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    72

    Re: Listbox - append()!!!

    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.....

Similar Threads

  1. how to display the Listbox
    By arungupta_2jan in forum Symbian
    Replies: 4
    Last Post: 2009-03-03, 21:10
  2. problem in ListBox
    By aditighosal in forum Symbian
    Replies: 8
    Last Post: 2008-07-16, 20:01
  3. Listbox...
    By harsh_vs in forum Symbian User Interface
    Replies: 2
    Last Post: 2008-02-15, 20:29
  4. Full screen listbox skin not rendered correctly
    By template60 in forum Symbian
    Replies: 2
    Last Post: 2007-09-11, 04:34
  5. ListBox Errors
    By javadi82 in forum Symbian User Interface
    Replies: 7
    Last Post: 2006-11-08, 13:29

Posting Permissions

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