Luc <l...@sep.invalid> wrote:
> That's an eye catching topic title, isn't it?
Yes, indeed, and unnecessary. :)
> Everything works except that I can't scroll the monster. I can see
> the first half a dozen sets of boxes and can't reach the others.
Again, demo code or else it is not happening.
This scrolls 6000 text widgets just fine:
#!/usr/bin/wish
text .t -yscrollcommand [list .vsb set]
scrollbar .vsb -orient vertical -command [list .t yview]
grid .t .vsb -sticky news
for {set i 0} {$i < 6000} {incr i} {
text .st$i -width 40 -height 5
.t window create end -window .st$i
.t insert end \n
}
So there must be something else interfering.
> So I tried a canvas. But it won't scroll either! That's weird. I should
> be able to scroll a canvas.
For a canvas you have to explicitly tell it the area to scroll,
otherwise it won't scroll at all. Read the manpage carefully.
> What approach do you recommend in my case?
Not creating 6000 text widgets.
> Additional problem: I can only have so many child text widgets, more or
> less 4,200. With 5,000 the application won't load anymore, it crashes
> after trying for a few seconds. I wonder if that can be fixed too.
My code above creates 6000, no crash.
Changing 6000 to 60000 takes a few minutes to run, and consumes 437MB
of memory (according to top). But once up, scrolling to the bottom
happens just fine.
> Alright! It's a subtitle editor. One box for subtitle number, another one
> for subtitle timestamp, then another one for the original subtitle, one
> for the translated subtitle and another one for certain indications
> (e.g. character count, errors etc.) A feature length movie can have 1,200
> subtitles, that's 6,000 boxes.
No, that's 6,000 datapoints, which does not need to equate to 6,000
boxes.
You need enough boxes to fit on screen without scrolling, and you move
the 6,000 datapoints through the smaller set of boxes that are
on screen. The screen boxes let you look through a screen sized
peephole at the 6,000 datapoints, and "scrolling" moves the data
through the peephole.
https://wiki.tcl-lang.org/page/Virtual%20Scrolling