0

When uploading an image to a label in Tkinter, it appears black. Not white or blank like some other questions, I did check them, and although I may have missed something, none of the answers there worked for me. Essentially, I upload an image. It appears, however, it displays only a black image, instead of the image I was using. Here is my code:

#Imports are here
import tkinter as tk
from tkinter import * 
from tkinter.ttk import *
from PIL import Image, ImageTk

#Retrieving and opening image
img = ImageTk.PhotoImage(Image.open("AFile.ppm"))
label = Label(frametwo, image=img)
label.photo = img
label.grid(column=2,row=2)

This does not display an errors, the image just shows up weird. I have no clue as to why. Thanks in advance.

stovfl
  • 14,998
  • 7
  • 24
  • 51
Viv
  • 9
  • 3
  • Does this answer your question? [Importing PPM images with python and PIL module](https://stackoverflow.com/a/4299149/7414759) – stovfl May 24 '20 at 09:20
  • Maybe you have a plain (ASCII) PPM file - you could share it via Dropbox or Google Drive. If so, you can read it simply enough as in my answer here... https://stackoverflow.com/a/60316138/2836621 – Mark Setchell May 24 '20 at 11:40
  • Those do not answer my question unfortanently. – Viv May 24 '20 at 19:39
  • The reason being that I tried it in several image formats and it did the same thing. – Viv May 24 '20 at 19:40
  • @Viv ***tried it in several image formats***: Tell, which formats? – stovfl May 24 '20 at 22:03
  • PNG, PPM, JPEG, sorry I probably should have added that in the description. – Viv May 24 '20 at 22:38

0 Answers0