Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User orebla's Avatar
    Join Date
    Nov 2007
    Posts
    7
    Hi, I'm a newbie!!
    I've a problem with appuifw.Listbox() function.
    Example:

    Code:
    import appuifw
    
    appuifw.app.title = u'mSoftware'
    
    icon1 = appuifw.Icon(u"\mrestore.mbm", 0, 1)
    icon2 = appuifw.Icon(u"\mrestore.mbm", 2, 3)
               
    def primo_tasto():
        appuifw.note(u"Selezionato PRIMO", "info")
        
    def secondo_tasto():
        appuifw.note(u"Selezionato SECONDO", "info")
    
    entries = [(u"Primo", primo_tasto),
                (u"Secondo", secondo_tasto)]
    
               
    lb = appuifw.Listbox(entries, handler)
    I don't understand what is "handler"??
    And why the code doesn't work??

    Sorry for the bad english

    thank you

  2. #2
    Regular Contributor nlsp's Avatar
    Join Date
    Oct 2007
    Posts
    67
    Please read the documentation (PythonForS60_1_4_1_doc.pdf) available from the Sourceforge download area.

    But to answer your question, the handler parameter should be your callback function. It will be called whenever the select button is clicked while the listbox is active.
    The entries parameter should be a list of unicode objects or tuples in one of the following forms:
    Code:
    [u"entry 1", u"entry 2", ... ] -> simple textonly listbox
    [(u"entry 1", u"entry 1 line 2"), (u"entry 2 line 2"), ... ] -> double line
    [(u"entry 1", icon1), (u"entry 2", icon2), ... ] -> listbox with small icon
    [(u"entry 1, u"entry 1 line 2", icon1), ... ] -> double line with large icon
    Finally, you have to assign your lb to appuifw.app.body to make it active.

    Regards, Niels
    Last edited by nlsp; 2007-11-01 at 13:32. Reason: added code block

  3. #3
    Nokia Developer Moderator croozeus's Avatar
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,635
    Quote Originally Posted by orebla View Post
    Hi, I'm a newbie!!
    I've a problem with appuifw.Listbox() function.
    Example:

    Code:
    import appuifw
    
    appuifw.app.title = u'mSoftware'
    
    icon1 = appuifw.Icon(u"\mrestore.mbm", 0, 1)
    icon2 = appuifw.Icon(u"\mrestore.mbm", 2, 3)
               
    def primo_tasto():
        appuifw.note(u"Selezionato PRIMO", "info")
        
    def secondo_tasto():
        appuifw.note(u"Selezionato SECONDO", "info")
    
    entries = [(u"Primo", primo_tasto),
                (u"Secondo", secondo_tasto)]
    
               
    lb = appuifw.Listbox(entries, handler)
    I don't understand what is "handler"??
    And why the code doesn't work??

    Sorry for the bad english

    thank you
    Hello orebla and welcome to the Forum !!

    In the line
    Code:
    lb = appuifw.Listbox(entries, handler)
    hadler is a callback function and you should define its body! I cant see it definition in your code so the code doest work!

    So you should define it at follows
    Code:
    def handler():
     index = lb.current()
     print index
     print entries[index]
    You can also find such bitexamples at http://croozeus.googlepages.com/appuifw_module

    Hope that helps
    Pankaj Nathani
    www.croozeus.com

  4. #4
    Super Contributor lfd's Avatar
    Join Date
    May 2006
    Location
    Oulu, Finland
    Posts
    622
    Hi

    The handler or observer is a function that will be called when you press the 'Select' button of the joystick. You have to define what that function have to perform; usually it gets the current selected item id of the list and then do some interesting stuff with it.

    If you need to catch other key event you can use the bind method. As an example you want the key 5 to have the same behavior than the select you'll do:
    Code:
    lb.bind(Key5, handler)
    Now, since all those signals are coming from a UI element, it __has__ to be set to the application body:
    Code:
    appuifw.app.body = lb
    LFD
    Devices:
    Nokia E61 3rd Edition - pys60 1.4.0

    Tips and modules:
    http://www.lfdm.net/thesis

  5. #5
    Registered User orebla's Avatar
    Join Date
    Nov 2007
    Posts
    7
    Thank you for answer.

    Ok, in the example in this page: http://croozeus.googlepages.com/appuifw_module

    the function shout() print the number of the item that's select by the user.

    But I don't understand how insert an instruction to execute a code if the user select "Signal" or "Battery".

    Example:

    I select: "Signal"
    The script create a windows info with:
    Code:
    Appuifw.note(u"Signal option selected", 'info')
    But how?

    I try to insert a "IF" in the function shout() but don't work...

    Thank you

  6. #6
    Nokia Developer Moderator croozeus's Avatar
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,635
    Quote Originally Posted by orebla View Post
    Thank you for answer.

    Ok, in the example in this page: http://croozeus.googlepages.com/appuifw_module

    the function shout() print the number of the item that's select by the user.

    But I don't understand how insert an instruction to execute a code if the user select "Signal" or "Battery".

    Example:

    I select: "Signal"
    The script create a windows info with:
    Code:
    Appuifw.note(u"Signal option selected", 'info')
    But how?

    I try to insert a "IF" in the function shout() but don't work...

    Thank you
    Hello orebla

    Try the following code.I think this is what you needed.

    Code:
    import e32
    import appuifw
     
    choices =[(u"Option1Text", "option1action"),
              (u"Option2Test", "option2action")]
    choices_labels = [x[0] for x in choices]
     
       
    def handle_selection():
        index = lb.current()
        code = choices[index][1]
        lb.set_list([u"Please wait..."])
        if code == "option1action":
            appuifw.note(u"here is where we process option1", 'info')
           
            
        elif code == "option2action":
            appuifw.note(u"here is where we process option2", 'info')
        else:
            appuifw.note(u"no valide code detected", 'error')
        lb.set_list(choices_labels)
     
    def handle_add():
        pass  
     
    def handle_delete():
        pass
     
    def exit_key_handler():
        app_lock.signal()
     
    lb = appuifw.Listbox(choices_labels, handle_selection)
     
    old_title = appuifw.app.title
    appuifw.app.title = u"Listbox UI"
    appuifw.app.body = lb
    appuifw.app.menu = [(u"Add new item", handle_add),
                        (u"Delete item", handle_delete)]
    appuifw.app.exit_key_handler = exit_key_handler
     
    app_lock = e32.Ao_lock()
    app_lock.wait()
     
    appuifw.app.title = old_title
    The code displays info msg when options1 or option 2 are selected...
    You can modify the code to your requirement to Show Battery and Signal respectively...

    Hope that helps

    Best Regards
    croozeus
    Pankaj Nathani
    www.croozeus.com

  7. #7
    Registered User orebla's Avatar
    Join Date
    Nov 2007
    Posts
    7
    Yes!
    Thanks!


    Now I understand how to do!

    Thank you!

Similar Threads

  1. Full screen listbox skin not rendered correctly
    By template60 in forum Symbian C++
    Replies: 2
    Last Post: 2007-09-11, 04:34
  2. Query ~ Listbox | functional but no text
    By series60nubee in forum Symbian C++
    Replies: 5
    Last Post: 2006-03-24, 06:09
  3. Using a "custom" listbox in mobile s60
    By ctpthanh in forum Symbian User Interface
    Replies: 4
    Last Post: 2005-04-17, 14:46
  4. Hide Listbox not working with MakeVisible(EFalse)
    By Salvesh in forum Symbian User Interface
    Replies: 3
    Last Post: 2005-02-04, 05:04
  5. listbox and model
    By stenlik in forum Symbian C++
    Replies: 1
    Last Post: 2004-05-27, 07:27

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved