title: why function does not work to get display image on label tkinter python, but it works not using function
body: <p>This code without function does work to get display image on label tkinter python 3.8.5.</p>
  <pre><code>    from tkinter import *
      from PIL import Image, ImageTk
      import os
      import os.path
  
      root = Tk()
      root.title(&quot;Test_image&quot;)
      root.geometry(&quot;1000x600&quot;)
  
      # def display_image():
      images_folder = &quot;C:/TextSoundSource/B-V/I-WORD-E-00-B-V-0-renamed&quot;
      os.chdir(images_folder)
      displaying_img = &quot;022.jpg&quot;
  
      # Open Image
      img = Image.open(displaying_img)
  
      # Resize Image
      resized = img.resize((300, 200), Image.ANTIALIAS)
      resized_img = ImageTk.PhotoImage(resized)
  
      image_display_frame = LabelFrame(root, text=&quot;Image&quot;, font=(
           &quot;times&quot;, 15, &quot;bold&quot;), bg=&quot;Navyblue&quot;, fg=&quot;white&quot;, bd=5)
      image_display_frame.place(x=0, y=0, width=1000, height=300)
  
      img_label = Label(image_display_frame, image=resized_img)
  
      img_label.pack(pady=20)
  
      # display_image()
      root.mainloop()
  </code></pre>
  <p><a href="https://i.stack.imgur.com/WP1BU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WP1BU.png" alt="getting image works" /></a></p>
  <p>But when using function like below it does not work, how do I get images by using function?</p>
  <pre><code>    from tkinter import *
      from PIL import Image, ImageTk
      import os
      import os.path
  
      # == == == == == == == == == == == ======== 
      # Using function does not work ???? why ???
      # == == == == == == == == == == == ========
  
      root = Tk()
      root.title(&quot;Test_image&quot;)
      root.geometry(&quot;1000x600&quot;)
  
      def display_image():
          images_folder = &quot;C:/TextSoundSource/B-V/I-WORD-E-00-B-V-0-renamed&quot;
          os.chdir(images_folder)
          displaying_img = &quot;001.jpg&quot;
  
          # Open Image
          img = Image.open(displaying_img)
  
          # Resize Image
          resized = img.resize((300, 200), Image.ANTIALIAS)
  
          resized_img = ImageTk.PhotoImage(resized)
  
          image_display_frame = LabelFrame(root, text=&quot;Image&quot;, font=(
              &quot;times&quot;, 15, &quot;bold&quot;), bg=&quot;Navyblue&quot;, fg=&quot;white&quot;, bd=5)
          image_display_frame.place(x=0, y=0, width=1000, height=300)
  
          img_label = Label(image_display_frame, image=resized_img)
          img_label.pack(pady=20)
  
      display_image()
      root.mainloop()
  </code></pre>
  <p><a href="https://i.stack.imgur.com/IlZ5r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IlZ5r.png" alt="Using function does not work to get image display, why?" /></a></p>
  <p>I appreciate in advance, please let me know how to get image display by using function in tkinter python.</p>