title: Adding an Image to a Canvas using askopenfilename()
body: <p>I'm trying to get a <code>.gif</code> image to go into a canvas after being selected from my PC using <code>filedialog.askopenfilename()</code>. The canvas will take the image if I:</p>
  
  <ol>
  <li>Don't put it in a <code>def</code> and</li>
  <li>Do not use the <code>filedialog</code>, but I can't see why this would not work...</li>
  </ol>
  
  <pre><code>from tkinter import *
  root=Tk()
  root.geometry("600x600")
  root.config(background="#FFFFFF")
  
  canvas = Canvas(width=200,height=200)
  canvas.grid(row=0,column=0)
  
  
  def create_image():
      profileimage = filedialog.askopenfilename()
      i = PhotoImage(file=profileimage)
      canvas.create_image(0,0,image=i)
  
  b = Button(text="Click", command=create_image).grid(row=1,column=0)
  </code></pre>