@omz, I am just playing with the dialogs.form_dialog. Just putting a wrapper around it. But the result returned from the function is only the last field filled in. I am really not sure if I am using it wrong or if there is a bug. I am trying to be a little smarter than I normally am, and that maybe what is making it go wrong. But at least from what I can see, it should work.
import dialogs
from collections import namedtuple
_form_fields = ['type', 'title', 'value', 'key', 'tint_color',
'icon', 'placeholder', 'autocorrection', 'autocapitalization']
DlgFld = namedtuple('DlgFld', _form_fields)
DlgFld.__new__.__defaults__ = ('text', '', '', None, '', None, '', False, False)
class UIFormSection(object):
def __init__(self, section='General', footer=None, *args, **kwargs):
self.section = section
self.footer = footer
self.flds = []
def add_field(self, **kwargs):
self.flds.append(DlgFld(**kwargs))
def get_section(self):
return (self.section, [f._asdict() for f in self.flds], self.footer)
class UIFormDialog(object):
def __init__(self, title='My Dialog', *args, **kwargs):
self.sections = []
self.title = title
def add_section(self, sec_obj):
self.sections.append(sec_obj)
def show(self):
section_lst = [s.get_section() for s in self.sections]
x = dialogs.form_dialog(title=self.title, sections=section_lst)
return x
if __name__ == '__main__':
# create a my dialog object
dlg = UIFormDialog('Users Toops')
# create a section for the dialog and add fields to it...
sec_user = UIFormSection('User Details')
sec_user.add_field(type='text',
title='First Name',
placeholder='Enter First Name',
autocapitalization=True)
sec_user.add_field(type='text',
title='Last Name',
placeholder='Enter Last Name',
autocapitalization=True)
sec_user.add_field(type='number',
title='Age',
placeholder='Enter Age')
sec_user.add_field(type='password',
title='password',
placeholder='Users Password')
sec_user.add_field(type='switch', title='Related')
# create another section and fields
sec_troops = UIFormSection('Troops')
sec_troops.add_field(type='number',
title='Infantry',
placeholder='Enter the number of Infantry troops')
sec_troops.add_field(type='number',
title='Ranged',
placeholder='Enter the number of Ranged troops')
sec_troops.add_field(type='number',
title='Cavalry',
placeholder='Enter the number of Cav troops')
dlg.add_section(sec_user)
dlg.add_section(sec_troops)
result = dlg.show()
print(result)