Python tkinter.simpledialog() Examples

The following are 1 code examples of tkinter.simpledialog(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tkinter , or try the search function .
Example #1
Source File: gui_02.py    From Modern-Python-Standard-Library-Cookbook with MIT License 8 votes vote down vote up
def dialog(ask, title, message=None, **kwargs):
    for widget in (messagebox, simpledialog, filedialog):
        show = getattr(widget, 'ask{}'.format(ask), None)
        if show:
            break
    else:
        raise ValueError('Unsupported type of dialog: {}'.format(ask))

    options = dict(kwargs, title=title)
    for arg, replacement in dialog.argsmap.get(widget, {}).items():
        options[replacement] = locals()[arg]
    return show(**options)