def demo_form_load_def(self, mt, opts): """ loads a form from its JSON representation and displays it """ form = Form(mt) with file(os.path.join(self.data_dir, 'form_def.json'), 'rt') as fp: form.load_definition(fp.read()) content = form.render_and_input() print('form content: %s' % content)
def demo_form_dump_def(self, mt, opts): """ generates the JSON representation of a form """ form = Form(mt) form.add_prompt(0, 2, 'First name') form.add_prompt(0, 4, 'Last name') form.add_prompt(30, 23, 'ENVOI') form.add_field('fname', 15, 2, 20) form.add_field('lname', 15, 4, 20) print(form.dump_definition())
def demo_form(self, mt, opts): """ displays a hard-coded form """ form = Form(mt) form.add_prompt(0, 2, 'First name') form.add_prompt(0, 4, 'Last name') form.add_prompt(30, 23, 'ENVOI') form.add_field('fname', 15, 2, 20) form.add_field('lname', 15, 4, 20) content = form.render_and_input({'fname': 'Eric'}) print('form content: %s' % content)