我无法使用 label.configure 更改图像

I can't change the image using label.configure

我正在尝试创建一个可以在其中处理图像的 GUI,因此我必须将默认图像更改为通过浏览按钮选择的图像。 默认图像消失但新图像不出现。请帮助! 这是我的代码:

from Tkinter import *
from tkFileDialog import askopenfilename
import cv2

class Browse_image :
    def __init__ (self,master) :

        frame = Frame(master)
        frame.grid(sticky=W+E+N+S)
        self.browse = Button(frame, text="Browse", command = lambda: self.browseim())
        self.browse.grid(row=13, columnspan=2)
        self.check = Checkbutton(frame, text="On/Off")
        self.check.grid(row=0)
        self.maxval = Scale(frame, from_=0, to=100, orient=HORIZONTAL)
        self.maxval.grid(row=1,columnspan=2)
        self.minval = Scale(frame, from_=0, to=100, orient=HORIZONTAL)
        self.minval.grid(row=2,columnspan=2)
        self.photo = PhotoImage(file="browse.png")
        self.label = Label(frame, image=self.photo)
        self.label.grid(row=3,rowspan=10)

    def browseim(self):
        path = askopenfilename(filetypes=(("png files","*.png"),("jpeg files","*.jpeg")) )
        if path:
            self.photo = PhotoImage(path)                        
            self.label.configure(image = self.photo)
            #self.label.image = self.photo
            #self.label.grid(row=3,rowspan=10)


root= Tk()
b= Browse_image(root)
root.mainloop()

self.photo = PhotoImage(path) 更改为 self.photo = PhotoImage(file=path)。在 PhotoImage class.

中定义图像路径需要 file 参数