一切正常,我没有收到任何错误,但图像没有显示。
我尝试将实际文件路径添加为:
image_test = PhotoImage(file = "E:/python/camera.png")
from tkinter import *
class BuckysButtons:
def __init__(self,master):
frame = Frame(master)
frame.pack()
image_test = PhotoImage(file = "camera.png")
self.printButton = Button(frame, image =image_test, text ="Print Message", compound ="top",command = self.printMessage)
self.printButton.pack(side = LEFT)
self.quitButton = Button(frame, text ="quit", command = frame.quit)
self.quitButton.pack(side=LEFT)
def printMessage(self):
print("It worked!")
root = Tk()
b = BuckysButtons(root)
root.mainloop()
我没有错误,但是图像没有显示。