I am trying to display a PGM image in Tkinter window, however I keep getting the error of "couldn't recognize data in image file". Is there something wrong with my code??
import tkinter as tk
from tkinter import filedialog
from tkinter import *
from tkinter import PhotoImage
def browse_file(self):
path = filedialog.askopenfilename()
if len(path) > 0:
photo = tk.PhotoImage(file=path)
cv = tk.Canvas()
cv.pack(side='top', fill='both', expand='yes')
cv.create_image(10, 10, image=photo, anchor='nw')