Skip to content

Instantly share code, notes, and snippets.

@bron84
Created June 3, 2016 08:28
Show Gist options
  • Select an option

  • Save bron84/ca79219a85006caae6c8193a28224329 to your computer and use it in GitHub Desktop.

Select an option

Save bron84/ca79219a85006caae6c8193a28224329 to your computer and use it in GitHub Desktop.
form_dialog_from_fields_dict_py3.py
# coding: utf-8
import collections, dialogs
# simplify the creation of simple form_dialogs
def form_dialog_from_fields_dict(title, fields_dict):
return dialogs.form_dialog(title, [{'title': k, 'type': v}
for k, v in fields_dict.items()])
# left side is the field name
# right side is the field data type
my_fields_dict = collections.OrderedDict((
('name', 'text'),
('age', 'number'),
('developer', 'switch'),
('web page', 'url'),
('email address', 'email'),
('password', 'password'),
('check', 'check'),
('datetime', 'datetime'),
('date', 'date'),
('time', 'time')))
print((form_dialog_from_fields_dict('My form dialog', my_fields_dict)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment