'Get a numerical selection.
:param int max: The maximum entry (len of choices), must be positive
:returns: tuple of the form (`code`, `selection`) where
`code` - str display exit code (\'ok\' or cancel\')
`selection` - int user\'s selection
:rtype: tuple'

def _get_valid_int_ans(self, max_):

    selection = (-1)
    if (max_ > 1):
        input_msg = "Select    the    appropriate    number    [1-{max_}]    then    [enter]    (press    'c'    to    cancel):    ".format(max_=max_)
    else:
        input_msg = "Press    1    [enter]    to    confirm    the    selection    (press    'c'    to    cancel):    "
    while (selection < 1):
        ans = input_with_timeout(input_msg)
        if (ans.startswith('c') or ans.startswith('C')):
            return (CANCEL, (-1))
        try:
            selection = int(ans)
            if ((selection < 1) or (selection > max_)):
                selection = (-1)
                raise ValueError
        except ValueError:
            self.outfile.write('{0}**    Invalid    input    **{0}'.format(os.linesep))
    return (OK, selection)
