def runDialog(dlg, mayCancel, *itemNames):
    """Run the specified dialog and return the values of the named items.
    Return None if the user cancels.
    """
    while True:
        if dlg.ShowModal() == wx.ID_OK:
            result = tuple((dlg.FindWindowByName(name).GetValue()
                            for name in itemNames))
            break
        elif mayCancel:
            result = None
            break
        else:
            wx.Bell()
    return result
Run the specified dialog and return the values of the named items.
    Return None if the user cancels.
    
recipes/Python/496868_Easily_creating_dialog_boxes_XRC/recipe-496868.py