From: Harald Oehlmann on
On 24 Mai, 19:00, Will Duquette <w...(a)wjduquette.com> wrote:
> I'm wanting to create a tablelist widget whose requested width derives
> from the columns defined in the widget.  This is not the normal way to
> use tablelist; the -width option is the width in characters of the -
> font.  I don't see any obvious way to make it happen.  Any ideas?

Perhaps a piece of semirelated code. I wanted to have a TableList and
an X Scrollbar.
If there is enough space, I wanted that the table widget takes all
available gridding space.
I digged this out, because there is the transformation "width in
characters" to "width in pixels" included.

set WiTable $WiFrameList.l
grid [scrollbar $WiFrameList.sx -orient horizontal\
-command [list $WiTable xview] -takefocus 0]\
-row 1 -column 0 -sticky ew
tablelist::tablelist $WiTable\
-xscrollcommand [list $WiFrameList.sx set]
grid $WiTable -row 0 -column 0 -sticky news
bind $WiTable <Configure> [namespace code [list TableConfigure
$WiTable]]
proc gui::TableConfigure {WiTable} {
set WidthCur [winfo width $WiTable]
if {[winfo reqwidth $WiTable] < $WidthCur} {
set CharWidth [expr {\
$WidthCur / [font measure [$WiTable cget -font] "0"]}]
} else {
set CharWidth 0
}
$WiTable configure -width $CharWidth
}

First  |  Prev  | 
Pages: 1 2
Prev: Timing TCL code
Next: ttk::combobox and Win7 artefact