我有一张要显示的图像,我想调整(实际上是放大)该图像的大小。这是我的代码,使用其他 SO 问题,但我没有得到任何结果 - 我的图像仍然具有相同的大小。调整按钮大小也不会改变图像大小。
我已经尝试了这个 SO 问题的答案:Image resize under PhotoImage but they won't work。
from Tkinter import *
root = Tk()
root.withdraw()
def cleanUp():
root.destroy()
def openWebsite():
print 'Will try to implement opening the website here.'
window = Toplevel(root)
window.protocol('WM_DELETE_WINDOW', cleanUp)
photo = PhotoImage(file="Header.pgm")
photo.zoom(2)
button = Button(window, image=photo, command=openWebsite)
button.pack()
root.mainloop()