title: Opening and reading a file with askopenfilename
body: <p>I have the following code where I'm trying to allow the user to open a text file and once the user has selected it, I would like the code to read it (this isn't a finished block of code, just to show what I'm after).</p>
  
  <p>However, I'm having difficulties either using tkFileDialog.askopenfilename and adding 'mode='rb'' or using the code like below and using read where it produces an error.</p>
  
  <p>Does anyone know how I can arrange to do this as I don't wish to have to type Tkinter.'module' for each item such as Menu and Listbox. Beginner to Tkinter and a bit confused! Thanks for the help!</p>
  
  <pre><code>import sys
  from Tkinter import *
  import tkFileDialog
  from tkFileDialog import askopenfilename # Open dialog box
  
  fen1 = Tk()                              # Create window
  fen1.title("Optimisation")               #
  
  menu1 = Menu(fen1)
  
  def open():
  
      filename = askopenfilename(filetypes=[("Text files","*.txt")])
      txt = filename.read()
      print txt
      filename.close()
  
  fen1.mainloop()
  </code></pre>
  
  <p>Obviously the error I'm getting here is:</p>
  
  <pre><code>AttributeError: 'unicode' object has no attribute 'read'
  </code></pre>
  
  <p>I don't understand how to use the askopen and also be able to read the file I'm opening.</p>