Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Who can tell me how to display a photo fully?

3 views
Skip to first unread message

lzs

unread,
Nov 23, 2009, 7:46:10 AM11/23/09
to
I am a novice. I want to create and completely display a map,the code
bottom is what i use,but it display the jpg only a little
part...besides,how do I make it the size of change with the size of
the window.
Any suggestions will be greatly appreciated. Thanks!


package require Img
frame .b
image create photo picture -file 33.jpg
canvas .b.c
pack .b.c
.b.c create image 1 1 -anchor nw -image picture
pack .b

Donal K. Fellows

unread,
Nov 23, 2009, 8:55:56 AM11/23/09
to
On 23 Nov, 12:46, lzs <lzs1...@live.cn> wrote:
> I am a novice. I want to create and completely display a map,the code
> bottom is what i use,but it display the jpg only a little
> part...besides,how do I make it the size of change with the size of
> the window.

You need to tell the canvas to scroll. This is done by adding
scrollbars and by defining the scrollable area, like this:

package require Img
pack [frame .b]
image create photo MyMap -file 33.jpg

# Make the canvas and logically connect the scrollbars to it
canvas .b.c -xscroll {.b.h set} -yscroll {.b.v set} -
highlightthickness 0
scrollbar .b.h -orient horizontal -command {.b.c xview}
scrollbar .b.v -orient vertical -command {.b.c yview}

# We use grid because it is easier to do the layout right that way
grid .b.c .b.v -sticky nsew
grid .b.h -sticky nsew
grid columnconfigure .b 0 -weight 1
grid rowconfigure .b 0 -weight 1

# Now add the image and tell the canvas that's what is scrolling
over
.b.c create image 1 1 -anchor nw -image MyMap -tag mymap
.b.c configure -scrollregion [.b.c bbox mymap]

Donal.

0 new messages