def dialog(self, content, buttons_and_results, title=None, bind_enter_esc=True, focus_buttons=False, extra_bindings=[]):

    class ResultSetter():

        def __init__(subself, res):
            subself.res = res

        def __call__(subself, btn):
            self.quit_event_loop = [subself.res]
    Attr = urwid.AttrMap
    if bind_enter_esc:
        content = SignalWrap(content)

        def enter(w, size, key):
            self.quit_event_loop = [True]

        def esc(w, size, key):
            self.quit_event_loop = [False]
        content.listen('enter', enter)
        content.listen('esc', esc)
    button_widgets = []
    for btn_descr in buttons_and_results:
        if (btn_descr is None):
            button_widgets.append(urwid.Text(''))
        else:
            (btn_text, btn_result) = btn_descr
            button_widgets.append(Attr(urwid.Button(btn_text, ResultSetter(btn_result)), 'button', 'focused button'))
    w = urwid.Columns([content, ('fixed', 15, urwid.ListBox(urwid.SimpleListWalker(button_widgets)))], dividechars=1)
    if focus_buttons:
        w.set_focus_column(1)
    if (title is not None):
        w = urwid.Pile([('flow', urwid.AttrMap(urwid.Text(title, align='center'), 'dialog title')), ('fixed', 1, urwid.SolidFill()), w])

    class ResultSettingEventHandler():

        def __init__(subself, res):
            subself.res = res

        def __call__(subself, w, size, key):
            self.quit_event_loop = [subself.res]
    w = SignalWrap(w)
    for (key, binding) in extra_bindings:
        if isinstance(binding, str):
            w.listen(key, ResultSettingEventHandler(binding))
        else:
            w.listen(key, binding)
    w = urwid.LineBox(w)
    w = urwid.Overlay(w, self.top, align='center', valign='middle', width=('relative', 75), height=('relative', 75))
    w = Attr(w, 'background')
    return self.event_loop(w)[0]
def dialog(self, content, buttons_and_results, title=None, bind_enter_esc=True, focus_buttons=False, extra_bindings=[]):

    class ResultSetter():

        def __init__(subself, res):
            subself.res = res

        def __call__(subself, btn):
            self.quit_event_loop = [subself.res]
    Attr = urwid.AttrMap
    if bind_enter_esc:
        content = SignalWrap(content)

        def enter(w, size, key):
            self.quit_event_loop = [True]

        def esc(w, size, key):
            self.quit_event_loop = [False]
        content.listen('enter', enter)
        content.listen('esc', esc)
    button_widgets = []
    for btn_descr in buttons_and_results:
        if (btn_descr is None):
            button_widgets.append(urwid.Text())
        else:
            (btn_text, btn_result) = btn_descr
            button_widgets.append(Attr(urwid.Button(btn_text, ResultSetter(btn_result)), 'button', 'focused button'))
    w = urwid.Columns([content, ('fixed', 15, urwid.ListBox(urwid.SimpleListWalker(button_widgets)))], dividechars=1)
    if focus_buttons:
        w.set_focus_column(1)
    if (title is not None):
        w = urwid.Pile([('flow', urwid.AttrMap(urwid.Text(title, align='center'), 'dialog title')), ('fixed', 1, urwid.SolidFill()), w])

    class ResultSettingEventHandler():

        def __init__(subself, res):
            subself.res = res

        def __call__(subself, w, size, key):
            self.quit_event_loop = [subself.res]
    w = SignalWrap(w)
    for (key, binding) in extra_bindings:
        if isinstance(binding, str):
            w.listen(key, ResultSettingEventHandler(binding))
        else:
            w.listen(key, binding)
    w = urwid.LineBox(w)
    w = urwid.Overlay(w, self.top, align='center', valign='middle', width=('relative', 75), height=('relative', 75))
    w = Attr(w, 'background')
    return self.event_loop(w)[0]