| Reply | « Previous Thread | Next Thread » |
|
Sorry to be thick, but how do I actually get data back from forms?
For example, in my Settings function, I have: state = [u'On', u'Off'] svalue = [u'1 bar',u'2 bars', u'3 bars'] data = [(u'Audible metronome','combo', (state,0)),(u'Tuning length','combo', (svalue,0))] flags = appuifw.FFormEditModeOnly+appuifw.FFormDoubleSpaced f = appuifw.Form(data, flags) f.execute() But how are the two choices returned to me? Help! Thanks, Steve Litchfield |
| slitchfield |
| View Public Profile |
| Find all posts by slitchfield |
|
Just use the [] operator on the form-object. Here is code that shows content of form-object.
Code:
f.execute() for label, tname, value in f: print label, tname, value |
| simo.salminen |
| View Public Profile |
| Find all posts by simo.salminen |
|
Quote:
Cheers Steve |
| slitchfield |
| View Public Profile |
| Find all posts by slitchfield |
|
Just to reiterate where I am with this. Here's the code I'm currently using:
state = [u'Off', u'On'] svalue = [u'1 bar',u'2 bars', u'3 bars'] data = [(u'Audible metronome','combo', (state,soundflag)),(u'Tuning length','combo', (svalue,tuninglength))] flags = appuifw.FFormEditModeOnly+appuifw.FFormDoubleSpaced f = appuifw.Form(data, flags) f.execute() From what's been written below, I'd expect my variables in the 'value' fields to be changed when the user selects different options. But they're not. Whatever I select in the dialog, their values don't change.... Any ideas? Cheers Steve Litchfield |
| slitchfield |
| View Public Profile |
| Find all posts by slitchfield |
|
You can get the values with the following code:
self.soundflag = int(f[0][2][1]) self.tuninglength = int(f[1][2][1]) Note the int(). I am very new to Python but it looks like form contains selected index as Long when Form is saved and I needed to convert back to Int to use them in data = [(u"Audible metronome",'combo',(self.state, self.soundflag)), (u'Tuning length','combo', (self.svalue, self.tuninglength))] |
|
Quote:
Thanks for your help so far! I'm sure we can work this out and I'll then post a working example of form use for others to use. Steve Litchfield |
| slitchfield |
| View Public Profile |
| Find all posts by slitchfield |
|
Do not worry about self in my code snippet. I put your example in a small test app that had a class. You can remove it in your example.
I use indexes to access the result of a form from its data list and tuples. If you consider the example form below (variation of your example): countries = [u"Switzerland", u"France", u"Deutschland", u"Italia"] data = [(u"Name", 'text', name), (u"Country", 'combo', (countries, country_code))] flags = appuifw.FFormEditModeOnly f = appuifw.Form(data, flags) f.execute() I get name with name = f[0][2] index 0 refers to 1st item in form data list index 2 refers to the value within the tuple (u"Name", 'text', name) I get country_code with country_code = f[1][2][1] index 1 refers the 2nd item (country) within list index 2 refer to the value within the tuple (u"Country", 'combo', (countries, country_code)) index 1 refer to the combo's index within the tuple (countries, country_code) A good example for using forms with DB is Sports_diary.py from the examples of Nokia SDK. I use the same pattern of methods in my application. |
|
Thanks, I'll give all that a whirl today!
Steve |
| slitchfield |
| View Public Profile |
| Find all posts by slitchfield |
|
Works fine, thanks, the example quoted should tell people all they need to know about getting data back from forms.
If anyone's interested, I've just released Musician 1.5, with configurable settings and a fladgling shareware nag screen system. Still fully working, of course, but I live in hope of someone actually registering it one day 8-) Thanks to everyone for their nuggets of wisdom over the last few days, I've acknowledged this forum in my code! Steve Litchfield |
| slitchfield |
| View Public Profile |
| Find all posts by slitchfield |
|
Hi, im a newbie so please bear with my questions regarding pys60 programming. In addition to sir palmac127's question, I would like to ask you guys a couple of questions:
These are slightly OT questions, sorry for this. 1. How can I retrieve the form field's value or data inside a function. Referring to sir adywicaksono's previous solution: . . . . # Menambahkan menu-menu pada objek Form def fungsi1(): appuifw.note(u"Menu 1","info") #------------------------------------------------ # How can I retrieve the values of the form fields #from inside this function? Please help me out. Many Thanks ------------------------------------------------ def fungsi2(): appuifw.note(u"Menu 2","info") daftarMenuForm = [ (u"Menu1",fungsi1), (u"Menu2",fungsi2)] # Daftar field dalam Form fieldForm = [(u"Nama","text"), (u"Alamat","text")] # set the view/edit mode of the form flags = appuifw.FFormAutoLabelEdit frmId = appuifw.Form(fieldForm,flags) frmId.menu = daftarMenuForm frmId.execute() appuifw.app.exit_key_handler = exit_key_handler app_lock.wait() 2. For my second question, I would like to ask you guys on how can I assign a value from a form field. Let say I would assign "Francis" as the value of the Nama text field in the previous solution. 3. Lastly, I was wondering if it is possible to set specific field on the form to act as readonly form field---meaning users are not able to put or enter data to that text field for example. This field will on only be used for displaying output or computed values. If this is possible kindly post the solution/s. Thank you guys, and looking forward for your replies soon. |
|
I was able to retrieve the form field value by first saving the form entries via the options menu and using frmId[0][2] to retrieve the form field value. Can it be possible to retrieve the form field value without pressing Save from the option menu?
|
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| suckho, i have encontered the same problems. Could you tell me how you resolved it? | dicson_hu | Symbian Networking & Messaging | 4 | 2005-12-09 11:56 |
| GPRS connection problems on 6600.. | suckho | Symbian Networking & Messaging | 10 | 2005-12-02 15:00 |
| 6600 gprs 发送大量rtp延时问题 | dicson_hu | Symbian | 9 | 2005-11-04 03:12 |
| Nokia 6600 Socket Server send delay Problem | dicson_hu | Mobile Java Networking & Messaging & Security | 1 | 2005-10-31 08:37 |
| Clarifications on User Data, User Data Binary and User Data Header | saijee | General Messaging | 2 | 2004-09-15 23:47 |