Quote:
>>> How can I make a listbox wider? Using horizontal scrollbars to get at the
>>> last 5 or 6 chars in the text doesn't seem worth it. (Besides, the customer
>>> wants all of the text visible.)
...
>>This will make the listbox fill whatever space it's put into while keeping
>>the scrollbar at a constant size. (bloated scrollbars are ugly)
>>Also take a look at the -geometry argument ...
> I suspect the original question is yet unanswered, and it's
> one I've been wondering about also. How can I get the listbox
> to scale its width to the width of the text I put into it?
Okay, you're probably right.
Note: I've seen claims by HCI people that windows which resize themselves
on their own whims are disconcerting to users. In my work, when I've
made windows which resized themselves people have complained and we ended
up making them either not change or change very little.
At any rate this job requires some TCL and uses the -geometry
argument. Listbox geometry is in terms of character widths so there
isn't any groady calculations involving characters being so many pixels
wide in the current font + n pixels of blank area. Instead It is
simply a matter of occasionally inspecting the strings and
$top.l -configure -geometry =widthxheight
(or whatever the correct notation is. I'm nowhere near any tk manuals.)
A convenient time would be when you add a new string to the listbox.
One way is to surround the listbox with a module full of functions (my
interp module should come in handy). In the add-string method you see
if this string is longer than the previous maximum string and, if so,
call the set-geometry method. The delete-string method must update
the maximum length of course.
To the above add:
--
<- ska: David le casse\*'