2016-06-12 177 views
0

이미지가 표시되고 크기를 조정하고 싶습니다 (실제로는 확대). 여기에 내 코드가 있는데 다른 SO 질문을 사용하고 있지만 아무런 결과도 얻지 못합니다. 이미지의 크기는 여전히 같습니다. 버튼 크기를 조절해도 이미지 크기는 변경되지 않습니다.Tkinter를 사용하여 pgm 이미지 크기 조정

나는이 질문에서 대답을 시도했다 : Image resize under PhotoImage하지만 그들은 작동하지 않습니다.

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() 

답변

2

PhotoImage.zoom()반환 새로운 이미지, 원본 이미지를 수정하지 않습니다.

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. 
: 도움에서

photo = photo.zoom(2) 

이 같은 photo 리 바인딩 시도