title: I want to open a file dialogue and pass the location of selected file as argument to tkinter to show on gui?
body: <p>I am facing the problem that the filedialogue is returning _io.TextIOWrapper object while tkinter takes location of the file as string.</p>
  <p>I tried every method to convert this _io.TextIOWrapper to string but failed .</p>
  <p>Help me out!!</p>
  <pre><code>import tkinter as tk
  import tkinter.filedialog
  
  from PIL import Image, ImageTk
  
  
  class App(tk.Tk):
      def __init__(self):
        super().__init__()
  
        self.main = tk.Frame(self)
        self.main.grid(row=0, column=0)
  
        dial = tkinter.filedialog.askopenfile()
  
        self.disp_img = Image.open(dial).resize((400, 400))
        self.disp_img = ImageTk.PhotoImage(self.disp_img)
  
        self.img_label = tk.Label(self.main, image=self.disp_img)
        self.img_label.grid(row=0, column=0)
  
  
  if __name__ == '__main__':
     app = App()
     app.withdraw()
     app.mainloop()
  </code></pre>