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

  1. Newsgroups: comp.lang.tcl
  2. Path: sparky!uunet!gatech!darwin.sura.net!jvnc.net!yale.edu!qt.cs.utexas.edu!cs.utexas.edu!torn!nott!bnrgate!bcars6a8!bnr.ca!norm
  3. From: norm@bnr.ca (Norm MacNeil)
  4. Subject: Re: dynamically changing text on labels
  5. Message-ID: <1992Dec22.153318.3371@bcars6a8.bnr.ca>
  6. Sender: usenet@bcars6a8.bnr.ca (Use Net)
  7. Nntp-Posting-Host: bcarh1ff
  8. Reply-To: norm@bnr.ca
  9. Organization: Bell-Northern Research Ltd.
  10. References: <1992Dec21.190502.23117@choreo.ca> <1992Dec22.143948.18360@cpu.com>
  11. Date: Tue, 22 Dec 1992 15:33:18 GMT
  12. Lines: 40
  13.  
  14. In article <1992Dec22.143948.18360@cpu.com>, gwlester@cpu.com (Gerald W. Lester) writes:
  15. |> In article <1992Dec21.190502.23117@choreo.ca>, news@choreo.ca (Choreo NetNews Administration Account(Ottawa)) writes:
  16. |> >I have a window set up with a number of label widgets for presenting info to
  17. |> >the user which they cannot change.  If they press a push button, I would
  18. |> >like to get the labels updated.  The support code is there to reset some
  19. |> >stuff, but how can I change the labels?  Using the label command only gets
  20. |> >me the expected error that the window exists in the parent.
  21. |> >
  22. |> >Any suggestions or other ideas would be helpful.
  23. |> >
  24. |> >Thanks, and Happy Holidays to all.
  25. |> 
  26. |> If you create a label with the command:
  27. |> 
  28. |>     label .my_label -text foo_bar
  29. |> 
  30. |> to change the label to snafu all you do is:
  31. |> 
  32. |>     .my_label configure -text snafu
  33. |> 
  34.  
  35. I think an easier way is to use the -textvariable parameter when defining the
  36. label:
  37.  
  38.   label .my_label -textvariable MyLabelVar
  39.   set MyLabelVar "initial value"
  40.  
  41. Then, whenever the variabel MyLabelVar changes, it automatically gets updated
  42. on the screen.  I have used this when I wanted a "drop-down" button to display
  43. values that the user could choose from but the value has to be displayed on
  44. the screen as well in "read-only" fashion.
  45.  
  46. Hope this helps,
  47.   Norm.
  48.  
  49. +-----------------------------------------------------------------------+
  50.  Norm MacNeil                     Phone: (613) 763-3372
  51.  Data Systems                     Fax:   (613) 765-2854
  52.  Bell-Northern Research Ltd.      EMail: norm@bnr.ca (INTERNET)
  53.  #include <disclaimer.std>       "Roller bladers do it in-line!"
  54.