×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Regular Contributor
    Join Date
    May 2008
    Posts
    86

    Create a form and save preferences

    Hi everybody, I would like to create a preferences menu for my app.
    I used this to create the form, but I would store choices and show them when user wants to change them.
    I'm using two functions (save/load) with e32dbm module, but every time I try to use them something goes wrong.
    These are the functions:

    Code:
    def write_pref():
    	global scelte
    	db = e32dbm.open(PREF_FILE, "cf")
    	db[u"first"] = scelte[0]
    	db[u"second"] = scelte[1]
    	db.close()
    Code:
    def read_pref():
    	global scelte
    	db = e32dbm.open(PREF_FILE, "r")
    	scelte[0] = db[u"first"]
    	scelte[1] = db[u"second"]
    	db.close()
    where scelte is a 2 items array in which I store the position the chosen elements to focus on them opening the form.

    Code:
    	scelte[0] = first.find(myForm.getFirst( ))
    	scelte[1] = second.find(myForm.getSecond( ))
    Code:
    self._iFields = [( u'First', 'combo', ( self._iFirst, scelte[0] ) ),
    ( u'Second', 'combo', ( self._iSecond, scelte[1] ) )]
    What am I doing wrong?

  2. #2
    Regular Contributor
    Join Date
    Dec 2007
    Location
    Tempe, AZ
    Posts
    411

    Re: Create a form and save preferences

    hi nufun,
    it would be better if you could tell the exact error message you are getting or is the output something else then you expected.
    IDEAS is all they need but still they think only Genius can give them that.

  3. #3
    Super Contributor
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976

    Re: Create a form and save preferences

    Quote Originally Posted by nufun View Post
    I'm using two functions (save/load) with e32dbm module, but every time I try to use them something goes wrong.
    Howabout just a plain old-fashioned totally non-sexy ASCII (unicode) text file?

    Much easier to handle, you can "debug" settings with text editor and it's a lot easier to use and definitely uses less phone resources (CPU time, memory, disk space).

    Database seems like a serious overkill for application settings. As you have noticed, it's also more difficult to use. Might be more interesting, but takes time away from "real" application development.

    Simple is Good,

    --jouni

  4. #4
    Regular Contributor
    Join Date
    May 2008
    Posts
    86

    Re: Create a form and save preferences

    Code:
    Howabout just a plain old-fashioned totally non-sexy ASCII (unicode) text file?
    I think I'll follow your suggestion!
    With e32db file it's impossible to understand where the error is!
    In my case I thought my error was in the db, instead it was find that didn't work! I replaced it with index and now I get element position to focus!
    Now I need to store this position but I think I'll do it with a simple text file.
    Thanks for your suggestion! Knowing e32db is a problem for everyone makes me fill better! I was afraid it was me!
    But if so: what is the really advantage from it?

  5. #5
    Super Contributor
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976

    Re: Create a form and save preferences

    Quote Originally Posted by nufun View Post
    Knowing e32db is a problem for everyone makes me fill better! I was afraid it was me!
    But if so: what is the really advantage from it?
    Sometimes you have a lot of info, for example phone cell (MCC, MNC, LAC, Cell ID) with GPS info (lots of data), current date and time and possible signal info. All of this once a second for example for 2 hours: 60 sec * 60 min * 2 h == 7200 lines * "lot of data". It can be saved into a text file, but handling it is much easier when you can use SQL.

    The advantage is when you need to do something with a LOT OF DATA. Searching, filtering, comparing, looking for patterns, replacing a with b etc.

    Cheers,

    --jouni who would like to do what was described above as soon as possible

  6. #6
    Regular Contributor
    Join Date
    May 2008
    Posts
    86

    Re: Create a form and save preferences

    Thanks for the explanation! I'm using text file and everything is ok now!
    Is there a way to display a multi-selection list with previous selected elements?
    My preferences are ok, I can see the result, but when I open the multiselection list to change them, the list is clear, nothing checked: I need a way to let user known what he selected!

  7. #7
    Super Contributor
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976

    Re: Create a form and save preferences

    Quote Originally Posted by nufun View Post
    Is there a way to display a multi-selection list with previous selected elements?
    My preferences are ok, I can see the result, but when I open the multiselection list to change them, the list is clear, nothing checked: I need a way to let user known what he selected!
    Strange, the source code does contain array for selected items, but there is no way to set it up with python!?!

    Code:
    int sz = PyList_Size(list);
    ...
    CArrayFixFlat<TInt> *selected_items = NULL;
    TRAP(error,
           selected_items = new(ELeave) CArrayFixFlat<TInt>(sz));
    
    ...
    dlg = CAknMarkableListDialog::NewL(index, selected_items, items_list,
    	  R_AVKON_DIALOG_EMPTY_MENUBAR);
    Looks like a missing feature.

    Sorry,

    --jouni

  8. #8
    Regular Contributor
    Join Date
    May 2008
    Posts
    86

    Re: Create a form and save preferences

    Missing feature?

  9. #9
    Super Contributor
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976

    Re: Create a form and save preferences

    Quote Originally Posted by nufun View Post
    Missing feature?
    Huh, sorry. Banging my head into brick wall with timers... Got animation working reasonably ok with arrow keys and Sensor API, but python crashes if user tries to exit while animation timer is still going on. Timer.cancel() simply does not work at all, no matter what I do. Will have write a defect report.

    "Missing feature" meant that list API would allow giving a list of selected items, but for some weird reason PyS60 has not implemented it. It doesn't even look difficult, most likely ignored by mistake. Should write a CR or defect report == defect handling is easier process, so I would recommend that. Check SourceSorge.

    Cheers,

    --jouni

Similar Threads

  1. How do I add a label to a form?
    By slamb in forum Symbian User Interface
    Replies: 3
    Last Post: 2008-03-03, 07:45
  2. Help in Making Form
    By vbvb in forum Symbian
    Replies: 1
    Last Post: 2007-08-30, 21:30
  3. Should I really be using a form?
    By Enfors in forum Symbian
    Replies: 10
    Last Post: 2007-08-03, 14:28
  4. 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
  •  
×