title: Browse image inside a tkinter frame
body: <p>I have a code that includes opening a pop-up window then browsing an image from the directory and i have to place it in an image frame. The problem is i can't fin d a way to place the image in the frame without having the pop-up window opening without pressing the load button or the directory opening without pressing the browse button here is where i am stuck in my code:</p>
  <pre><code>import tkinter as tk
  from tkinter.filedialog import askopenfilenames
  from PIL import Image, ImageTk
  
  
  window = tk.Tk()
  window.title('Intialization')
  window.geometry('350x250')
  
  
  def browsefunc():
      filename = tk.filedialog.askopenfilename(initialdir='initial/directory.. ')
      img = Image.open('%s' % filename)
      image = ImageTk.PhotoImage(img)
      imageFrame = tk.Frame(left_frame, width=200, height=200, bg='grey')
      imageFrame.grid(column=1, row=1, pady=5)
      canvas = tk.Canvas(imageFrame, height=200, width=200)
      canvas.image = image
      canvas.create_image(0, 0, image=image)
  
  
  def new_window():
      window2 = tk.Toplevel(window)
      window2.title('Pop-Up 1')
      window2.geometry('600x400')
      left_frame = tk.Frame(window2, width=300, height=400)
      left_frame.grid(row=0, column=0)
      right_frame = tk.Frame(window2, width=100, height=400)
      right_frame.grid(row=0, column=1)
      browse_btn = tk.Button(right_frame, text='Browse', command=browsefunc)
      browse_btn.grid(row=0, column=1, pady=5)
      window2.grab_set()
  
  
  load_btn = tk.Button(window, text=&quot;Load&quot;, command=new_window)
  load_btn.place(relx=0.5, rely=0.5, anchor=tk.CENTER)
  window.mainloop()
  </code></pre>
  <p>In this code i can't open the image since the left_frame is not defined prior but i posted it to explain my goal. I want my image to browse and open in the left frame without the directory opening before pressing browse.</p>