(edge, allocation, direction)
Work out how far edge is from a particular point on the allocation
    rectangle, in the given direction
Work out how far edge is from a particular point on the allocation
    rectangle, in the given direction
Work out how far edge is from a particular point on the allocation rectangle in the given direction
def get_nav_offset(edge, allocation, direction):
    """Work out how far edge is from a particular point on the allocation
    rectangle, in the given direction"""
    if direction == 'left':
        return(edge - (allocation.x + allocation.width))
    elif direction == 'right':
        return(allocation.x - edge)
    elif direction == 'up':
        return(edge - (allocation.y + allocation.height))
    elif direction == 'down':
        return(allocation.y - edge)
    else:
        raise ValueError('Unknown direction: %s' % direction)
def get_nav_offset ( edge , allocation , direction ) : if direction == 'left' : return ( edge - ( allocation . x + allocation . width ) ) elif direction == 'right' : return ( allocation . x - edge ) elif direction == 'up' : return ( edge - ( allocation . y + allocation . height ) ) elif direction == 'down' : return ( allocation . y - edge ) else : raise ValueError ( 'Unknown direction: %s' % direction )