title: image = ImageTk.PhotoImage with variables
body: <p>So basically, I want to open an Image with <code>image = ImageTk.PhotoImage()</code> and it works fine with</p>
  
  <pre><code>image = ImageTk.PhotoImage(file="C:/Users/timol/PycharmProjects/Test1/haha.jpg")
  </code></pre>
  
  <p>Earlier in the code I saved a path in a variable which is</p>
  
  <pre><code>def click():
      file = askopenfilename(initialdir='C:/Users/%s')
      directory = os.path.split(file)[0]
      print(directory)
  </code></pre>
  
  <p>Now, I want to use the path saved in "directory" to put in <code>image = ImageTk.PhotoImage(file= "directory")</code>
  But it just gives me a lot of errors.</p>
  
  <p>In case you need to know, I want to do that, because I want the User later on to be able to upload an image and display/use in the program.</p>
  
  <p>here's the entire code: </p>
  
  <pre><code>`from tkinter import *
  from PIL import ImageTk, Image, ImageDraw
  import PIL
  import os
  from tkinter import filedialog
  
  root = Tk()
  root.title("Zahlenerfassung")
  root.geometry("500x400")
  topFrame = Frame(root)
  topFrame.pack()
  bottomFrame = Frame(root)
  bottomFrame.pack(side=BOTTOM)
  def create(): command=os.system("start "+"pepsi.txt")
  #def click():
      # Get the file
     # file = askopenfilename(initialdir='C:/Users/%s')
      # Split the filepath to get the directory
  #  directory = os.path.split(file)[0]
  #   print(directory)
  
  def click():
       image_file_location = filedialog.askopenfilename(initialdir="C:/Users/%s")
       image = ImageTk.PhotoImage(file=image_file_location)
       canvas.create_image(50, 50, image=image, anchor=NW)
  
  button1 = Button(topFrame, text="Bild auswerten", fg="red")
  button2 = Button(bottomFrame, text="Erstelle ein Bild", fg="blue", command=lambda: create())
  button3 = Button(bottomFrame, text="Lade dein Bild hoch", fg="blue", command=lambda: click())
  
  canvas = Canvas(width=200, height=200)
  canvas.pack(expand=NO, fill=NONE)
  
  button1.pack(side=LEFT)
  button2.pack(side=LEFT)
  button3.pack(side=LEFT)
  
  one = Label(root, text="", fg="white")
  one.pack(fill=BOTH, expand=TRUE)
  root.mainloop()
  </code></pre>