Created
June 3, 2016 08:28
-
-
Save bron84/ca79219a85006caae6c8193a28224329 to your computer and use it in GitHub Desktop.
form_dialog_from_fields_dict_py3.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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