def no_account(): def do_register(): login = login_field.get_value() passwd = passwd_field.get_value() mail = mail_field.get_value() if not login or not passwd or not mail: ui.message('Fill all fields.') elif passwd != passwd_repeat_field.get_value(): ui.message('Passwords don\'t match.') else: request(logged, 'register', login, passwd, mail) panel = ui.LinearLayoutWidget() login = ui.HorizontalLayoutWidget() login.add(ui.Label('Login:'******'Password:'******'*') passwd.add(passwd_field) panel.add(passwd) passwd_repeat = ui.HorizontalLayoutWidget() passwd_repeat.add(ui.Label('Repeat password:'******'*') passwd_repeat.add(passwd_repeat_field) panel.add(passwd_repeat) mail = ui.HorizontalLayoutWidget() mail.add(ui.Label('Mail:')) mail_field = ui.EditField() mail.add(mail_field) panel.add(mail) butts = ui.HorizontalLayoutWidget(spacing=10) butts.add(ui.Button('Register', do_register)) butts.add(ui.Button('Cancel', ui.back)) panel.add(butts) ui.set(panel)
def show_login_form(callback, msg=None): def logged(result): print 'Login successful' with open(save.get_save_dir() + '/civsync.sessid.txt', 'w') as f: f.write(session.sessid) callback() def do_login(): ui.back(anim=False) request(logged, 'login', login_field.get_value(), passwd_field.get_value()) def no_account(): def do_register(): login = login_field.get_value() passwd = passwd_field.get_value() mail = mail_field.get_value() if not login or not passwd or not mail: ui.message('Fill all fields.') elif passwd != passwd_repeat_field.get_value(): ui.message('Passwords don\'t match.') else: request(logged, 'register', login, passwd, mail) panel = ui.LinearLayoutWidget() login = ui.HorizontalLayoutWidget() login.add(ui.Label('Login:'******'Password:'******'*') passwd.add(passwd_field) panel.add(passwd) passwd_repeat = ui.HorizontalLayoutWidget() passwd_repeat.add(ui.Label('Repeat password:'******'*') passwd_repeat.add(passwd_repeat_field) panel.add(passwd_repeat) mail = ui.HorizontalLayoutWidget() mail.add(ui.Label('Mail:')) mail_field = ui.EditField() mail.add(mail_field) panel.add(mail) butts = ui.HorizontalLayoutWidget(spacing=10) butts.add(ui.Button('Register', do_register)) butts.add(ui.Button('Cancel', ui.back)) panel.add(butts) ui.set(panel) panel = ui.LinearLayoutWidget() login = ui.HorizontalLayoutWidget() login.add(ui.Label('Login:'******'Password:'******'*') passwd.add(passwd_field) panel.add(passwd) butts = ui.HorizontalLayoutWidget(spacing=10) butts.add(ui.Button('Login', do_login)) butts.add(ui.Button('No account?', no_account)) butts.add(ui.Button('Cancel', ui.back)) panel.add(butts) ui.set(panel, anim=False) if msg and msg != 'Not logged': ui.message(msg)