title: check which entry is focused (Python)
body: <p>I am working with Python v3.4 and using <code>Tkinter</code> library to workout my GUI.</p>
  <p>I have included an on-screen keyboard in my python app. The problem is as follow:</p>
  <p>They are three entries:</p>
  <pre><code>username = Entry(root,font=&quot;Verdana 22&quot;)
  
  password = Entry(root, font=&quot;Verdana 22&quot;)
  
  courrierEntry = Entry(root, font=&quot;Verdana 22&quot;)
  </code></pre>
  <p>Below is the keyboard</p>
  <pre><code> def select(value):
          if value == &quot;BACK&quot;:
              entry2 = len(username.get()[:-1])
  
          username.delete(entry2, END)
  
      elif value == &quot; Space &quot;:
              username.insert(END, ' ')
  
      elif value == &quot; Tab &quot;:
              username.insert(END, '    ')
  
      else:
              username.insert(END, value)
  
  buttons = [
      'q','w','e','r','t','y','u','l','o','p','BACK','7','8','9','-',
      'a','s','d','f','g','h','j','k','l','[',']','4','5','6','+',
      'z', 'x','c','v','b','n','m',',','.','?','1','2','3','/','HELP',
      ]
  
  varRow = 2
  varColumn = 0
  
  for button in buttons:
  
      command = lambda x = button: select(x)
      keyboardButton = Button(keyboardFrame, text = button, width = 8,  bg=&quot;#795548&quot;, fg=&quot;#ffffff&quot;,
              activebackground=&quot;#D7CCC8&quot;,activeforeground=&quot;#000000&quot;,relief = &quot;raised&quot;, padx=0,font=&quot;Verdana 11 bold&quot;,
              pady=8, bd=8, command = command)
      keyboardButton.grid(row = varRow, column = varColumn)
      varColumn += 1
      if varColumn &gt; 14 and varRow == 2:
          varColumn = 0
          varRow += 1
      if varColumn &gt; 14 and varRow == 3:
          varColumn = 0
          varRow +=1
  </code></pre>
  <p>As you may have notice in the keyboard, it only refers to the <code>username entry</code>, and hence even when not focused on the <code>username entry</code> whenever a button is pressed only the <code>username entry</code> reacts.</p>
  <p>I would want that to establish some kind of if statement, the problem is that I am not familiar with verifying if the entry is focused/selected. It should go by the entry currently selected and not by name. So essentially whenever I select I can type.</p>
  <p>Update:</p>
  <h1>------KEYBOARD----------</h1>
  <pre><code>#checking to see whcih input entry is currently focused
  inputFocus = None
  
  def currentEntry(userEntry):
      global inputFocus
      inputFocus = userEntry
  
  username.bind(&quot;&lt;FocusIn&gt;&quot;, lambda: currentEntry(username))
  password.bind(&quot;&lt;FocusIn&gt;&quot;, lambda: currentEntry(password))
  courrierEntry.bind(&quot;&lt;FocusIn&gt;&quot;, lambda: currentEntry(courrierEntry))
  
  
  def select(value):
      if value == &quot;BACK&quot;:
          entry2 = len(inputFocus.get()[:-1])
  
          inputFocus.delete(entry2, END)
  
      elif value == &quot; Space &quot;:
              inputFocus.insert(END, ' ')
  
      elif value == &quot; Tab &quot;:
              inputFocus.insert(END, '    ')
  
      else:
              inputFocus.insert(END, value)
  </code></pre>