comp.lang.tcl
[Top] [All Lists]

Re: How do you bind to a window size change?

Subject: Re: How do you bind to a window size change?
From: Arndt Roger Schneider
Date: Sat, 31 May 2008 14:59:49 +0200
Newsgroups: comp.lang.tcl


crvoss@xxxxxxxxxxx schrieb:
I have a very large table that I want to display and it must be done
in pure tcl (no external packages). My approach is to make a text
widget that shows a viewport of a portion of the table. Then only the
cells that are being viewed will be shown within the text widget. In
actuality the entry widgets within the text widget would never change
but the data would change in the entry widgets as the scrollbars were
moved. I hope that's clear. Anyway, my problem is that I can do the
above okay but when the text widget size (height and/or width) is
changed I want the reevaluate the number of cells in the viewport and
add or remove any if needed. My first shot at that is the following:

proc chgSize {} {
    set wdth [.txt cget -width]
    set x [expr {$wdth/18}]
    for {set i 0} {$i <= $x} {incr i} {
        destroy .txt.ent$i
        entry .txt.ent$i -width 15
        .txt window create end -window .txt.ent$i
    }
}
text .txt -wrap none -yscrollcommand ".vscroll set" -xscrollcommand
".hscroll set"
scrollbar .vscroll -command ".txt yview"
scrollbar .hscroll -command ".txt xview" -orient horizontal
pack .vscroll -side right -fill y
pack .hscroll -side botto propm -fill x
pack .txt -fill both -expand yes
chgSize
bind .txt <Configure> "chgSize"

However, this method does not let me actually resize the text widget.
So I'm stumped -- can anybody help?

Your code is ok -- with two exception however:
You must not use a text window for this!

The text managed entries do not "propagate"
their space to the text manager.

Use the grid manager to do this -- as does tktable.

The second point is:
Entries are horizontal scrollable and don’t propagate their
size requests either .. so wont work for them,too.


--roger

BTW:Don’t use pack, go for grid!

<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy