title: Bind or Command to get return and button to work
body: <p>I have a simple question about the <code>bind()</code> method and the <code>command</code> argument.
  Usually, in a program, you can click on a button related to what you are doing to execute something or simply press the return key. 
  In the code below, I tried to do the same and it does actually work. 
  I was just asking myself if the line <code>bttn.bind('&lt;Button-1&gt;', search)</code> isn't a bit strange, as it relates the mouse click inside the button to the function, and not the pressing of the button itself.</p>
  
  <p>At the beginning, I didn't want to include pressing the return key to execute the entry, and I had written <code>bttn = Button(wd, text='Search', bg='Light Green', command=search)</code>, but at that point the <code>search</code> function wasn't an event driven function and had no event argument.</p>
  
  <p>As soon as I wanted to include the return key pressing to do the same job, I had (of course) to write the function with <code>(event)</code>, and thus use the <code>bind()</code> method for the mouse button as well. </p>
  
  <p>Is this the <em>"best way"</em> to do it ? Or is there a more idiomatic way of doing it ? </p>
  
  <p>Python3/Windows</p>
  
  <pre><code>from tkinter import *
  
  def search(event):
      try:
          txtFile = open(str(entr.get()), 'r')
      except:
          entr.delete(0, END)
          entr.insert(0, "File can't be found")
      else:
          x = 0
          while 1:
              rd = txtFile.readline()
              if len(rd)&gt; x:
                  longest = rd
                  x = len(rd)
              elif rd == '':
                  break
          txtFile.close()
          entr.delete(0, END)
          entr.insert(0, longest)
  
  #####MAIN#####
  
  wd = Tk()
  wd.title('Longest sentence searcher')
  entr = Entry(wd, bg='White')
  entr.grid(row=0, column=0)
  entr.bind('&lt;Return&gt;', search)
  bttn = Button(wd, text='Search', bg='Light Green')
  bttn.grid(row=1, column =0)
  bttn.bind('&lt;Button-1&gt;', search)
  
  wd.mainloop()
  </code></pre>