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



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!
.



Relevant Pages

  • Re: Do you agree, its a nonsense [winfo ismapped $x]?
    ... what it was some time before, when you created/deiconified that widget. ... In none of the popup dialogs I'm using "ismapped" - there's no need. ... pack .t.f.b1 ... objects can include the state variables as part of ...
    (comp.lang.tcl)
  • Re: tk widget
    ... Now where I set NOS for textvariable and use this variable when I bind is not working corrrectly. ... So, when you change the value in that textvariable, it changes every widget associated with that variable. ... foreach FN $SCR3 {set FN1 "Field $FN" frame .editFr$FN -borderwidth 10 pack .editFr$FN -side top -fill x ... The main drawback to binding on doesn't handle other cases such as when the user uses the tab or shift-tab key to go to a different field, or clicks in another field, etc. ...
    (comp.lang.tcl)
  • Re: How to rearrange already packed widgets?
    ... pack have been used while creating this UI. ... So I tried called 'grid ... default, if widget a was created before widget b, then widget a is below ... widget b in the stacking order and will be "covered" by widget b. ...
    (comp.lang.tcl)
  • Re: How do you bind to a window size change?
    ... cells that are being viewed will be shown within the text widget. ... pack .hscroll -side botto propm -fill x ... Use the grid manager to do this -- as does tktable. ...
    (comp.lang.tcl)
  • pack table widget
    ... I have looked through several table widget and they all have their own ... window, how do you write a table widget and pack it inside of a frame? ... label .incorrect_data_count -background white ...
    (comp.lang.tcl)