Forum Archive

Dialogs, and Forms.

AtomBombed

Can anybody point me to how to make a successful form dialog popup using the dialogs module? I have had trouble with it, and there is very minimal documentation provided on the subject. I keep getting errors, no matter what I do...

ccc

https://forum.omz-software.com/search/form_dialog

omz

@AtomBombed Could you post some code that you've tried, and what kind of errors you're getting?

Phuket2

@AtomBombed , I hope the below helps. The variables are named long on purpose. But if you look at the dialogs doc with this example, I think it should be clear.

import dialogs
import datetime


def show_list_dialog(title, items):
    return dialogs.list_dialog(title = title, items = items)

def show_form_dialog(title, fields):
    return dialogs.form_dialog(title = title, fields = fields)


if __name__ == '__main__':
    lst = ['red', 'blue', 'orange', 'purple']
    x = show_list_dialog(title = 'A List Dialog', items = lst)
    print x

    form_list_of_dicts = []

    form_list_of_dicts.append(dict(type = 'text', title = 'First Name',
    key = 'first', placeholder = 'Ole'))

    form_list_of_dicts.append(dict(type = 'text', title = 'Last Name',
    key = 'last', placeholder = 'Zorn')) 

    form_list_of_dicts.append(dict(type = 'date', title = 'Date Of Birth',
    key = 'DOB', value = datetime.date.today()))

    x = show_form_dialog(title = 'A Form Dialog', fields = form_list_of_dicts)
    print x