Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple scrollbar question 1

Status
Not open for further replies.

rubberscissors

Technical User
Oct 11, 2001
21
US
This is probably simple, but I can't seem to find the answer to this one; I'm building a tool that uses a lot of text widgets to display output, status messages, etc. and each widget uses a scrollbar.

I've got the messages etc. directed to the text widget without any problems and it works well, but using the command -yscrollcommand {.framepath.scroll set} results in the text just disappearing off the bottom of the widget...you can then use the scrollbar to scroll down and see what you're missing, but I'm trying to get it so that it continually shows you the latest entry, and allows you to scroll BACK to see what disappeared off the top of the widget, not the other way around. I've got a couple books to work from, but they just don't seem to get into this. Any ideas?
 
For text with scroll bars I use this:

set f .f
pack [frame $f]
set w [text $f.t]
frame $f._f_
set vsb [scrollbar $f._vsb_ -orient vertical -command "$w yview"]
set hsb [scrollbar $f._hsb_ -orient horizontal -command "$w xview"]
grid rowconfigure $f 0 -weight 3
grid columnconfigure $f 0 -weight 3
grid $w -row 0 -col 0 -sticky nsew -in $f
grid $vsb -row 0 -col 1 -sticky ns -in $f
grid $hsb -row 1 -col 0 -sticky ew -in $f
grid $f._f_ -row 1 -col 1 -sticky nsew -in $f
$w configure -yscrollcommand [list $vsb set] -xscrollcommand [list $hsb set]


ulis
 
rubberscissors: If you're inserting some text at the bottom of a Text widget, you can force the Text widget to scroll down the the end after the insertion like this:

[tt].t insert end "Here's another line.\n"
.t see end[/tt]

The Text widget's see operation is how you can programmatically scroll the widget. The argument can be any Text widget index. For example:

[tt].t see insert[/tt]

would scroll the Text widget .t to wherever the text insertion cursor was located. - Ken Jones, President
Avia Training and Consulting
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
Excellent! That did it - so simple...you know I couldn't find that actually written down anywhere? Thanks a bunch!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top