home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / tcl / 1841 < prev    next >
Encoding:
Internet Message Format  |  1992-11-16  |  2.5 KB

  1. Path: sparky!uunet!stanford.edu!agate!sprite.Berkeley.EDU!ouster
  2. From: ouster@sprite.Berkeley.EDU (John Ousterhout)
  3. Newsgroups: comp.lang.tcl
  4. Subject: Re: Button-size in pix's or frame-size in char's?
  5. Date: 16 Nov 1992 16:28:15 GMT
  6. Organization: U.C. Berkeley Sprite Project
  7. Lines: 47
  8. Distribution: world
  9. Message-ID: <1e8i6vINN8ek@agate.berkeley.edu>
  10. References: <1992Nov16.102838.17193@dxcern.cern.ch>
  11. NNTP-Posting-Host: tyranny.berkeley.edu
  12.  
  13. In article <1992Nov16.102838.17193@dxcern.cern.ch>, trones@dxcern.cern.ch (Jostein Lodve Trones) writes:
  14. |> 
  15. |> I hope somebody out there can help me with the following problem...
  16. |> 
  17. |> I am going to open a frame containing some buttons in columns and rows.
  18. |> Since I will do this quite often, and with a different number of buttons,
  19. |> I am writing a procedure to do this.
  20. |> 
  21. |> I use place instead of pack, because I want a somewhat speciall lay-out, 
  22. |> with space around the buttons.
  23. |> 
  24. |> The problem is that I need to know the size of the frame before I open it.
  25. |> But to calculate the size of the frame, I need to know the size of a button.
  26. |> The button's size is known in characters, but not in pixels.
  27. |> 
  28. |> I thought of using the winfo command to return the button-size in pixels,
  29. |> but this do not work, unless the button is already placed or packed in
  30. |> the frame, and the frame already packed/placed on the root-window, or 
  31. |> another packed/placed window.
  32. |> 
  33. |> So I have the famous "chicken-and-the-egg" problem: I can not calculate
  34. |> the size of the button, unless the frame is opened, and I can not open
  35. |> the frame unless I know the size of the button...
  36. |> (With "open" I mean place/pack the window so that it is visible on the screen)
  37. |> 
  38. |> I could of course first place the frame, then place a button on it, find
  39. |> the size and regeometrize(?) the frame, but is there a better way?
  40. |> 
  41. |> What I actually need, is a way to get the button's size in pixels when
  42. |> I know the size in characters, or a way to specify the frame-size in 
  43. |> characters.
  44. |> 
  45. |> 
  46. |> Thank you for any help!
  47. |> 
  48. |> Cheers,
  49. |>         Jostein
  50.  
  51. If you're using the packer to place the buttons into the frame then you
  52. don't need to pick the size of the frame yourself:  the packer will set
  53. the frame's size itself so that it's just large enough to contain all the
  54. information you've packed into it.
  55.  
  56. If for some reason you want to know how much space a button (or any other
  57. window) wants, you can always use "winfo reqheight" and "winfo reqwidth"
  58. to get that.  However this shouldn't be necessary in your case, unless I'm
  59. missing something.
  60.