title: Problem with tkinter text insert wordstart
body: <p>I tried to get the current word in a tkinter text widget. Here’s my code:</p>
  <pre><code>import tkinter as tk
  
  win = tk.Tk()
  
  text = tk.Text(win)
  text.insert('end', 'a b abc')
  text.pack(fill='both', expand=1)
  def get_word():
      global text
      print(repr(text.get('insert -1c wordstart', 'insert wordend')))
  
  tk.Button(win, text='Get Word', command=get_word).pack()
  
  win.mainloop()
  </code></pre>
  <p>When:</p>
  <ul>
  <li>The cursor is at the end of ‘a’ or ‘b’:<br />
  Returns  <code>‘a ‘</code> or <code>‘b ‘</code></li>
  <li>The cursor is at the end of ‘abc’:<br />
  Returns <code>‘abc\n’</code></li>
  <li>The cursor is in the word ‘abc’:<br />
  Returns <code>‘abc’</code></li>
  </ul>
  <p>I want to get the word right before the cursor, like when the cursor is after ‘b’, I want it to return ‘b’; return ‘abc’ when the cursor is after ‘abc’.</p>
  <p>So how can I do this? Thanks for any ideas!</p>