Hi Gaba88,
Actually in my application there is login form with fields "user name" and "password". This form has one command "Login". Now what I want is that when user enters user name and password information in the login form and press "Login" command, then those login details will be used to authenticate the user.
But here the problem is that user has to press "Save" before pressing "Login" then only user's input (login details) can be saved in the form and can be available to the program for any action. Is there any way to avoid pressing "Save"? I mean user will enter some inputs in the login form then press "Login" (without pressing "Save") and action of "Login" can read those form details to take some action accordingly.
Code:
import appuifw
login_details = {}
login_details['abcd'] = 'efgh'
login_details['aa'] = 'xx'
class MyForm:
def show(self):
fields = [( u'User Name', 'text', u''), (u'Password','text', u'')]
self.form = appuifw.Form(fields, appuifw.FFormEditModeOnly)
self.form.flags = appuifw.FFormEditModeOnly
self.form.menu = [(u'Login', self.on_login)]
self.form.execute()
def on_login(self):
user_name = str(self.form[0][2])
passwd = str(self.form[1][2])
if not user_name:
appuifw.note(u'User name is missing', 'error')
return
if not passwd:
appuifw.note(u'Password is missing', 'error')
return
print "user name is ", user_name
print "password is ", passwd
success = False
if login_details.has_key(user_name):
if passwd == login_details[user_name]:
success = True
if success:
appuifw.note(u'Login success', 'info')
## Do some action accordingly##
else:
appuifw.note(u'Invalid user name and/or password', 'error')
## Be in the same form ##
return
if __name__ == "__main__":
appuifw.app.title = u'Forms with save issue'
form = MyForm()
form.show()