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

help image scrolling

5 views
Skip to first unread message

suc...@wanadoo.fr

unread,
Apr 29, 2006, 12:19:25 PM4/29/06
to
Hello

after many difficulties i managed to get in the
text widget both an image and scrollbars.
I cannot find a way to scroll my image !!!
any help is welcomed
hereafter is my code
**********

#scrollbars
text .t -yscrollcommand {.s set}
scrollbar .s -command {.t yview}
pack .s -side right -fill y
pack .t -expand yes -fill both
#enabling jpeg
package require Img
#going to the image directory
cd C:/tmp/venise
#getting the image
set im [image create photo im -file 04.jpg]
#inserting image
.t image create end -image im

*******************
thank you
jerome

Aric Bills

unread,
Apr 29, 2006, 4:21:05 PM4/29/06
to
Scrolling has been enhanced in Tk 8.5. If you use the ActiveTcl 8.5
beta, an 8.5 tclkit, or some other incarnation of Tcl 8.5, your code
should work okay.

suc...@wanadoo.fr

unread,
Apr 29, 2006, 4:51:33 PM4/29/06
to
Hello Aric
i downloaded Tcl/Tk 8.5a4 from http://www.equi4.com/pub/tk/8.5a4/.
As you said it works fine. Since it has not the package "Img" i had
to convert my picture from "jpg" to "gif". Many thanks.
One more question please :
supposing there is no Tcl/Tk 8.5.x and i have only Tcl/Tk 8.4.x
how can i visualize pictures and scroll them horizontal and vertical ?
thanks in advance
jerome

On 29 Apr 2006 13:21:05 -0700, "Aric Bills" <aric....@gmail.com>
wrote:

Gerald W. Lester

unread,
Apr 29, 2006, 7:15:30 PM4/29/06
to
suc...@wanadoo.fr wrote:
> Hello Aric
> i downloaded Tcl/Tk 8.5a4 from http://www.equi4.com/pub/tk/8.5a4/.
> As you said it works fine. Since it has not the package "Img" i had
> to convert my picture from "jpg" to "gif". Many thanks.
> One more question please :
> supposing there is no Tcl/Tk 8.5.x and i have only Tcl/Tk 8.4.x
> how can i visualize pictures and scroll them horizontal and vertical ?
> thanks in advance

Prior to 8.5, text widgets minimum scrolling was a line at a time.

Try a canvas widget instead, as in:

package require image

scrollbar .hsb -orient horizontal -command [list .c xview]
scrollbar .vsb -orient vertical -command [list .c yview]
canvas .c \
-xscrollcommand [list .hsb set] \
-yscrollcommand [list .vsb set]
grid .c -row 1 -column 1 -sticky nsew
grid .vsb -row 1 -column 2 -sticky ns
grid .hsb -row 2 -column 1 -sticky ew
grid columnconfigure . 1 -weight 1
grid rowconfigure . 1 -weight 1

set im [image create photo im -file {04.jpg}

.c create image 0 0 -image im
.c configure -scrollregion [.c bbox all]

> jerome
>
>
>
> On 29 Apr 2006 13:21:05 -0700, "Aric Bills" <aric....@gmail.com>
> wrote:
>
>> Scrolling has been enhanced in Tk 8.5. If you use the ActiveTcl 8.5
>> beta, an 8.5 tclkit, or some other incarnation of Tcl 8.5, your code
>> should work okay.
>


--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+

Aric Bills

unread,
Apr 29, 2006, 7:46:32 PM4/29/06
to
I should have clarified in my earlier posting, the scrolling behavior
of the text widget is what was enhanced. Scrolling in general was
already quite good :)

I agree with Gerald, a canvas is probably the best way to allow users
to scroll an image.

You mentioned that the Tclkit you downloaded didn't have the Img
package. For what it's worth, you can use your current copy of Img
(and other Tcl extensions on your computer) with your new tclkit. When
you fire it up, just add the directory/directories where the extensions
live to the global variable $::auto_path. Something like:

lappend auto_path C:/tcl/lib

Then each time you call [package require], it will look in C:/tcl/lib
as well as any other directory in $auto_path.

suc...@wanadoo.fr

unread,
Apr 30, 2006, 5:42:49 AM4/30/06
to
Hello Gerald
thank you for the code, it works perfectly. On the other
hand i will study this working code since i am just
starting to handle canvas.
Thank you again
jerome

suc...@wanadoo.fr

unread,
Apr 30, 2006, 5:44:34 AM4/30/06
to
Hello Aric
thank you for the code showing me how i can use Img package
(and other of course) with Tcl/Tk 8.5.x
friendly
jerome

On 29 Apr 2006 16:46:32 -0700, "Aric Bills" <aric....@gmail.com>
wrote:

>I should have clarified in my earlier posting, the scrolling behavior

Don Porter

unread,
Apr 30, 2006, 10:50:12 AM4/30/06
to
suc...@wanadoo.fr wrote:
> i downloaded Tcl/Tk 8.5a4 from http://www.equi4.com/pub/tk/8.5a4/.
> As you said it works fine. Since it has not the package "Img"...

You should already have the Img package from your ActiveTcl 8.4
install. Use it.

--
| Don Porter Mathematical and Computational Sciences Division |
| donald...@nist.gov Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|

Don Porter

unread,
Apr 30, 2006, 10:51:43 AM4/30/06
to
Aric Bills wrote:
> ... When

> you fire it up, just add the directory/directories where the extensions
> live to the global variable $::auto_path. Something like:
>
> lappend auto_path C:/tcl/lib

Use the environment variable TCLLIBPATH to accomplish the same thing
with no need to hack the code itself.

suc...@wanadoo.fr

unread,
Apr 30, 2006, 2:08:16 PM4/30/06
to
Hello Gerald
thank you for the code it works perfectly. Since i am new to
canvas your code will help me practicing it.
thank you again
jerome

On Sat, 29 Apr 2006 18:15:30 -0500, "Gerald W. Lester"
<Gerald...@cox.net> wrote:

suc...@wanadoo.fr

unread,
Apr 30, 2006, 2:09:59 PM4/30/06
to
Hello Aric
thanks again for "lappend........" it wil help me to try
other things with Tcl/Tk 8.5x .
friendly
jerome

On 29 Apr 2006 16:46:32 -0700, "Aric Bills" <aric....@gmail.com>
wrote:

>I should have clarified in my earlier posting, the scrolling behavior

suc...@wanadoo.fr

unread,
Apr 30, 2006, 2:11:22 PM4/30/06
to
Hello Don
thank you for proposing a solution.
friendly
jerome
0 new messages