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

simultaneous scrolling of text widgets in paned window?

38 views
Skip to first unread message

tonytraductor

unread,
Apr 19, 2008, 1:52:42 PM4/19/08
to
Greetings, Tclers

Is there a way to place two text widgets in a paned window (yes, so
far), and bind them to the same scroll bar?

I tried this:

frame .t -bd 2 -relief sunken
panedwindow .t.t -orient vertical

# Here is the source text widget
########################################SOURCE TEXT WIDGET


.t.t add [text .t.t.source -yscrollcommand ".t.t.ys set" -wrap word -
maxundo 0 -undo true ]

# Here is the target text widget
###################################TARGET TEXT WIDGET


.t.t add [text .t.t.target -yscrollcommand ".t.t.ys set" -wrap word -
maxundo 0 -undo true ]


scrollbar .t.t.ys -command ".t.t.source yview"

pack .t.t.source -in .t.t -side left -fill both -expand true
pack .t.t.ys -in .t.t -side left -fill y
pack .t.t.target -in .t.t -side left -fill both -expand true
pack .t.t -in .t -fill both -expand true
pack .t -in . -fill both -expand true

But it doesn't seem to be working.
I figured giving them the same yscrollcommand would do it.

I'm trying to compare two texts (a source text and the translation
thereof), or open a source text and write in the translation, to join
the two files into
a .tmx or .xliff file.


Thanks,
Tony

--
http://www.baldwinlinguas.com
http://www.linguasos.org/bsoft/

Uwe Klein

unread,
Apr 19, 2008, 2:40:21 PM4/19/08
to
Hmm,
on syncronous scrolling:
http://wiki.tcl.tk/9254

On the other hand
you could "steal" most of your app from tkdiff
http://sourceforge.net/projects/tkdiff/
http://wiki.tcl.tk/3773
http://en.wikipedia.org/wiki/Tkdiff

It's got file loading and save,
a two pane syncronously scrollable textwidget
and should be a good start.

uwe

Aric Bills

unread,
Apr 19, 2008, 6:18:44 PM4/19/08
to
Uwe Klein pointed to Ulis' multiscrolling page, which demonstrates how
to use a couple of procedures to act as intermediaries between the
scrollbar and the scrolled widgets. Depending on how elaborate your
scrolling behavior needs to be, you may find it helpful to read over
the [scrollbar set] and "Scrolling commands" sections of the scrollbar
man page: http://www.tcl.tk/man/tcl8.5/TkCmd/scrollbar.htm#M25 and
http://www.tcl.tk/man/tcl8.5/TkCmd/scrollbar.htm#M26 .

I'd be interested to hear how you propose to keep the texts visually
aligned, given invariable differences in length between the source
text and the translation.

Neil Madden

unread,
Apr 20, 2008, 10:20:07 AM4/20/08
to
tonytraductor wrote:
> Greetings, Tclers
>
> Is there a way to place two text widgets in a paned window (yes, so
> far), and bind them to the same scroll bar?
...

> .t.t add [text .t.t.source -yscrollcommand ".t.t.ys set" -wrap word -
> maxundo 0 -undo true ]
>
> .t.t add [text .t.t.target -yscrollcommand ".t.t.ys set" -wrap word -
> maxundo 0 -undo true ]
>
>
> scrollbar .t.t.ys -command ".t.t.source yview"

Others have given more comprehensive answers, but this last line is the
source of the problem -- the scrollbar only alters one of the widget's
yview:

proc sendall {ws args} {
foreach w $ws { uplevel 1 $w $args }
}

set widgets {.t.t.source .t.t.target}
scrollbar .t.t.ys -command [list sendall $widgets yview]

-- Neil

0 new messages