2014-02-20 3 views
0

나는 사진 이미지가있는 GUI가 있습니다. 창은 원래 이미지의 크기와 정확히 일치합니다. 내가 원하는 것은 사용자가 창 크기를 조정할 때 이미지가 창에 맞게 크기가 조정되는 것입니다. "사진"명령의 문서를 기반으로, 나는 다음을 시도했다. 그러나 그것은 효과가없는 것처럼 보입니다. 이미지는 항상 같은 크기로 유지되고 창의 크기를 조정하면 크기를 조정하지 않고 일부만 숨 깁니다. -shrink 옵션의 기능을 이해하지 못합니까?tk의 창으로 이미지 크기를 조정하는 방법

package require Tk 

image create photo previewraw -file preview.pnm 
image create photo preview -file preview.pnm 

ttk::frame .c 
ttk::label .c.preview -image preview 

grid .c -column 0 -row 0 -sticky nwes 
grid .c.preview -column 0 -row 0 
grid columnconfigure . 0 -weight 1 
grid rowconfigure . 0 -weight 1 
grid columnconfigure .c 0 -weight 1 
grid rowconfigure .c 0 -weight 1 

bind .c.preview <Configure> { 
    preview copy previewraw -to 0 0 %w %h -shrink 
} 

답변

0

과 anwer는 다음과 같습니다

package require Tk 

image create photo preview -file preview.pnm 

ttk::frame .c 
ttk::label .c.preview -image preview 

grid .c -column 0 -row 0 -sticky nwes 
grid .c.preview -column 0 -row 0 
grid columnconfigure . 0 -weight 1 
grid rowconfigure . 0 -weight 1 
grid columnconfigure .c 0 -weight 1 
grid rowconfigure .c 0 -weight 1 

bind .c.preview <Configure> { 
    exec convert preview.pnm -resize %wx%h -background lightgray -gravity center -extent %wx%h newfile 
    preview read newfile -shrink 
} 
관련 문제