0

I have an image that I display and I would like to resize (enlarge, actually) that image. Here's my code, using other SO questions, but I get no result - my image still has the same size. Resizing the button also does not change the image size.

I've tried the answers from this SO question: 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()
Community
  • 1
  • 1
Jonas
  • 1,473
  • 2
  • 13
  • 28

1 Answers1

2

PhotoImage.zoom() returns a new image, it does not modify the original image. Try rebinding photo like this:

photo = photo.zoom(2)

From the help:

zoom(self, x, y='') method of Tkinter.PhotoImage instance
    Return a new PhotoImage with the same image as this widget
    but zoom it with X and Y.
mhawke
  • 84,695
  • 9
  • 117
  • 138