home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / tcl / 2258 < prev    next >
Encoding:
Text File  |  1992-12-28  |  2.5 KB  |  60 lines

  1. Newsgroups: comp.lang.tcl
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!ames!agate!netsys!ukma!david
  3. From: david@ms.uky.edu (David Herron -- a slipped disk)
  4. Subject: Re: making a listbox wider
  5. References: <1992Dec22.174743.3736@twg.com> 
  6.     <1992Dec26.021200.8087@hawk.cs.ukans.edu>
  7. Message-ID: <1992Dec28.124745.1857@ms.uky.edu>
  8. Date: Mon, 28 Dec 1992 17:47:45 GMT
  9. Organization: University Of Kentucky, Dept. of Math Sciences
  10. Lines: 48
  11.  
  12. In article <1992Dec26.021200.8087@hawk.cs.ukans.edu> shea@hawk.cs.ukans.edu (Gary Shea) writes:
  13. >In article <1992Dec22.174743.3736@twg.com> "David Herron" <david@twg.com> writes:
  14. >>> How can I make a listbox wider?  Using horizontal scrollbars to get at the
  15. >>> last 5 or 6 chars in the text doesn't seem worth it.  (Besides, the customer
  16. >>> wants all of the text visible.)
  17. ...
  18. >>This will make the listbox fill whatever space it's put into while keeping
  19. >>the scrollbar at a constant size.  (bloated scrollbars are ugly)
  20. >>
  21. >>Also take a look at the -geometry argument ...
  22. >
  23. >    I suspect the original question is yet unanswered, and it's
  24. >    one I've been wondering about also.  How can I get the listbox
  25. >    to scale its width to the width of the text I put into it?
  26.  
  27. Okay, you're probably right.
  28.  
  29. Note: I've seen claims by HCI people that windows which resize themselves
  30. on their own whims are disconcerting to users.  In my work, when I've
  31. made windows which resized themselves people have complained and we ended
  32. up making them either not change or change very little.
  33.  
  34. At any rate this job requires some TCL and uses the -geometry
  35. argument.  Listbox geometry is in terms of character widths so there
  36. isn't any groady calculations involving characters being so many pixels
  37. wide in the current font + n pixels of blank area.  Instead It is
  38. simply a matter of occasionally inspecting the strings and
  39.  
  40.     $top.l -configure -geometry =widthxheight
  41.  
  42. (or whatever the correct notation is.  I'm nowhere near any tk manuals.)
  43.  
  44. A convenient time would be when you add a new string to the listbox.
  45. One way is to surround the listbox with a module full of functions (my
  46. interp module should come in handy).  In the add-string method you see
  47. if this string is longer than the previous maximum string and, if so,
  48. call the set-geometry method.  The delete-string method must update
  49. the maximum length of course.
  50.  
  51. >><- David Herron <david@twg.com> (work) <david@davids.mmdf.com> (home)
  52.  
  53. To the above add:
  54.  
  55. <- David Herron <david@ms.uky.edu> (vacation)
  56.  
  57. -- 
  58. <- David Herron; an MMDF weenie                           <david@twg.com>
  59. <- ska: David le casse\*'
  60.