I've been attempting to force the "insert" mark to move to the start of a field of text irregardless of where the user clicks on that field. While I have found this post, it does not seem to work in my code. The cursor/insert simply stays at the index where I clicked (Nb: the rest of the function works fine). As a last idea I tried "return 'break'" in case some further function was being run that "restored" the cursor location, but that made no difference. I am using Python 3.4 and Tkinter 8+. Thank-you!!
...
n = ttk.Notebook(p)
n1 = Text(n,width=60,height=15);
...
def EnterStatement(e):
i=n1.index('current').split('.')
n1.tag_remove('NewStatement', i[0]+'.0', i[0]+'.0 lineend')
n1.replace(i[0]+'.16', i[0]+'.46', ' '*30,'flex')
#the following doesn't work... why?!
n1.mark_set('insert', i[0]+'.16')
...
n1.tag_bind("NewStatement",'<1>', EnterStatement)