0
CHONE_2Sc = tk.Tk()
FstAlien = ImageTk.PhotoImage(Image.open("alien.jpg"))
FstAlLabel = tk.Label(image=FstAlien)
FstAlien.show(command= "display")
FstAlien.pack()
CHONE_2Sc. configure(background="lime")
CHONE_2Sc.title("ROCK,PAPERS,SCISSORS")
Object = tk.Entry()
Object.grid(row=100, column=100)
Object.insert(0, "Enter your object: ")
Object.get()

In the review questions already on Stack Overflow to see if your question is a duplicate. There was a post that said that if you're using Mac, .open will show the image. On unix, display, fim and something else would do it. But on windows he didn't specify that much or I didn't understand that much.

Thingamabobs
  • 7,274
  • 5
  • 21
  • 54
  • 2
    Does this answer your question? [Why does Tkinter image not show up if created in a function?](https://stackoverflow.com/questions/16424091/why-does-tkinter-image-not-show-up-if-created-in-a-function) – Thingamabobs Jun 08 '23 at 14:48
  • It is not clear what your problem is. Better explain it more. – acw1668 Jun 08 '23 at 15:01

2 Answers2

0

Welcome, Abdullah. You need pack your label (FstAlLabel) not your image object (FstAlien). Here's one way.

FstAlien = ImageTk.PhotoImage(Image.open("alien.jpg"))
FstAlLabel = tk.Label(CHONE_2Sc, image=FstAlien)
FstAlLabel.pack()

If that doesn't work, add this line at the end too.

FstAlLabel.image = FstAlien
drchicken
  • 114
  • 9
0

Tkinter how to insert image using Pillow

You still have grid(row=100, column=100) layout problem. You also messed up grid()

I changed pack() to grid()

I do not understand .show(). Where did you get that?

Snippet:

import tkinter as tk
from PIL import Image, ImageTk


CHONE_2Sc = tk.Tk()

CHONE_2Sc.configure(background="lime")
CHONE_2Sc.title("ROCK,PAPERS,SCISSORS")

FstAlien = ImageTk.PhotoImage(Image.open("p1.png"))

FstAlLabel = tk.Label(CHONE_2Sc, image=FstAlien)
#FstAlien.show(command= "display")
FstAlLabel.grid(row=0, column=1)

 
Object = tk.Entry()
Object.grid(row=1, column=1)
Object.insert(0, "Enter your object: ")
Object.get()

CHONE_2Sc.mainloop()

Screenshot:

enter image description here

toyota Supra
  • 3,181
  • 4
  • 15
  • 19
  • 1
    I got show from another person who was asking this same question. I used it though it didn't work. Thank you for helping me. – Abdullah Karan Jun 09 '23 at 03:16