You Are Here:

Community: Developer Discussion Boards

#1 Old Getting data back from forms - 2006-02-22, 10:53

Join Date: Jan 2006
Posts: 67
slitchfield
Offline
Regular Contributor
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
Reply With Quote

#2 Old Re: Getting data back from forms - 2006-02-22, 11:23

Join Date: Aug 2004
Posts: 290
simo.salminen
Offline
Regular Contributor
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
Reply With Quote

#3 Old Re: Getting data back from forms - 2006-02-22, 14:19

Join Date: Jan 2006
Posts: 67
slitchfield
Offline
Regular Contributor
Quote:
Originally Posted by simo.salminen
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
Err... which [] operator? Your example didn't have any [] chars! In my code, should I be using my variables instead of those zeros?

Cheers
Steve
Reply With Quote

#4 Old Re: Getting data back from forms - 2006-02-22, 19:58

Join Date: Jan 2006
Posts: 67
slitchfield
Offline
Regular Contributor
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
Reply With Quote

#5 Old Re: Getting data back from forms - 2006-02-22, 21:42

Join Date: Apr 2003
Posts: 6
srouil
Offline
Registered User
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))]
Reply With Quote

#6 Old Re: Getting data back from forms - 2006-02-22, 21:58

Join Date: Jan 2006
Posts: 67
slitchfield
Offline
Regular Contributor
Quote:
Originally Posted by srouil
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))]
Interesting post, although Python gives an error, saying that 'self' is not defined. Also, I don't follow where you got the f[] array numbers from. Can you comment?

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
Reply With Quote

#7 Old Re: Getting data back from forms - 2006-02-23, 07:32

Join Date: Apr 2003
Posts: 6
srouil
Offline
Registered User
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.
Reply With Quote

#8 Old Re: Getting data back from forms - 2006-02-23, 08:58

Join Date: Jan 2006
Posts: 67
slitchfield
Offline
Regular Contributor
Thanks, I'll give all that a whirl today!

Steve
Reply With Quote

#9 Old Re: Getting data back from forms - 2006-02-23, 12:18

Join Date: Jan 2006
Posts: 67
slitchfield
Offline
Regular Contributor
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
Reply With Quote

#10 Old Re: Getting data back from forms - 2006-11-07, 02:32

Join Date: Nov 2006
Posts: 9
bandz_fab
Offline
Registered User
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.
Reply With Quote

#11 Old Re: Getting data back from forms - 2006-11-07, 03:45

Join Date: Nov 2006
Posts: 9
bandz_fab
Offline
Registered User
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 With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
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

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia