×

Discussion Board

Results 1 to 3 of 3

Thread: Save Form!!!

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

    Save Form!!!

    Hi all,

    I have to save the values used in my form.. Say for example I use the Form example from wiki.. But when I use it inside a function I am not able to save it..

    My code now is
    Code:
    import appuifw
    
    def Edit_Form():
        models = [u"6600", u"6630", u"7610", u"N90", u"N70"]
        fields = [(u"Company", 'text', u"Nokia"),
                  (u"Model", 'combo', (models, 0)),
                  (u"Amount",'number', 1)]
        flags=appuifw.FFormEditModeOnly
        saved = False
    
        def save(arg):
    	global saved
    	saved = True
    	return True
    
        myForm = appuifw.Form(fields,flags)
        myForm.save_hook = save
        myForm.execute()
    
        if saved == True:
    	print myForm[0][2]
    	print models[myForm[1][2][1]]
    	print myForm[2][2]
    	
    Edit_Form()
    What should I do to make the save function work from inside a function..

  2. #2
    Registered User
    Join Date
    Dec 2008
    Posts
    6

    Re: Save Form!!!

    The saved variable you test in Edit_Form is NOT global, it's local to the function. In the save function that you've defined, you change the value of the global variable saved. You then examine the value of the local variable saved in Edit_Form. You need to read a good Python book about variable scope. A working variant of your code is:

    Code:
    import appuifw
    
    def Edit_Form():
        global saved
        models = [u"6600", u"6630", u"7610", u"N90", u"N70"]
        fields = [(u"Company", 'text', u"Nokia"),
                  (u"Model", 'combo', (models, 0)),
                  (u"Amount",'number', 1)]
        flags=appuifw.FFormEditModeOnly
        saved = False
    
        def save(arg):
            global saved
            saved = True
            return True
    
        myForm = appuifw.Form(fields,flags)
        myForm.save_hook = save
        myForm.execute()
    
        if saved == True:
            print myForm[0][2]
            print models[myForm[1][2][1]]
            print myForm[2][2]
           
    Edit_Form()
    but it's very ugly.

  3. #3
    Super Contributor
    Join Date
    Feb 2008
    Location
    Belo Horizonte, Brazil
    Posts
    744

    Re: Save Form!!!

    You have to save the form data into a file/database if you want to load them in the next time you open the application. If you don't know how to read and write content into a file, take a look at this article. In case you still have any doubt after reading the article, feel free to ask again



    Hope it helps,

    Rafael.

Similar Threads

  1. how to save form data
    By rams.vundela in forum Symbian
    Replies: 6
    Last Post: 2009-03-16, 06:39
  2. Replies: 10
    Last Post: 2009-03-09, 09:09
  3. Form troubles
    By matdodgson in forum Symbian User Interface
    Replies: 2
    Last Post: 2008-12-06, 10:49
  4. Save Values from a FORM
    By Abhishek_karmakar in forum Symbian
    Replies: 8
    Last Post: 2008-10-04, 14:18
  5. Save and close form
    By kerfunkledbongle in forum Symbian User Interface
    Replies: 1
    Last Post: 2006-04-13, 19:23

Posting Permissions

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