'Cursor move begins at start or end of selection
When a left/right cursor key is pressed create and return to Tkinter a
function which causes a cursor move from the associated edge of the
selection.'

def move_at_edge_if_selection(self, edge_index):

    self_text_index = self.text.index
    self_text_mark_set = self.text.mark_set
    edges_table = ('sel.first+1c', 'sel.last-1c')
    def move_at_edge(event):
        if ((event.state & 5) == 0):
            try:
                self_text_index('sel.first')
                self_text_mark_set('insert', edges_table[edge_index])
            except TclError:
                pass
    return move_at_edge
