home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!stanford.edu!agate!sprite.Berkeley.EDU!ouster
- From: ouster@sprite.Berkeley.EDU (John Ousterhout)
- Newsgroups: comp.lang.tcl
- Subject: Re: Button-size in pix's or frame-size in char's?
- Date: 16 Nov 1992 16:28:15 GMT
- Organization: U.C. Berkeley Sprite Project
- Lines: 47
- Distribution: world
- Message-ID: <1e8i6vINN8ek@agate.berkeley.edu>
- References: <1992Nov16.102838.17193@dxcern.cern.ch>
- NNTP-Posting-Host: tyranny.berkeley.edu
-
- In article <1992Nov16.102838.17193@dxcern.cern.ch>, trones@dxcern.cern.ch (Jostein Lodve Trones) writes:
- |>
- |> I hope somebody out there can help me with the following problem...
- |>
- |> I am going to open a frame containing some buttons in columns and rows.
- |> Since I will do this quite often, and with a different number of buttons,
- |> I am writing a procedure to do this.
- |>
- |> I use place instead of pack, because I want a somewhat speciall lay-out,
- |> with space around the buttons.
- |>
- |> The problem is that I need to know the size of the frame before I open it.
- |> But to calculate the size of the frame, I need to know the size of a button.
- |> The button's size is known in characters, but not in pixels.
- |>
- |> I thought of using the winfo command to return the button-size in pixels,
- |> but this do not work, unless the button is already placed or packed in
- |> the frame, and the frame already packed/placed on the root-window, or
- |> another packed/placed window.
- |>
- |> So I have the famous "chicken-and-the-egg" problem: I can not calculate
- |> the size of the button, unless the frame is opened, and I can not open
- |> the frame unless I know the size of the button...
- |> (With "open" I mean place/pack the window so that it is visible on the screen)
- |>
- |> I could of course first place the frame, then place a button on it, find
- |> the size and regeometrize(?) the frame, but is there a better way?
- |>
- |> What I actually need, is a way to get the button's size in pixels when
- |> I know the size in characters, or a way to specify the frame-size in
- |> characters.
- |>
- |>
- |> Thank you for any help!
- |>
- |> Cheers,
- |> Jostein
-
- If you're using the packer to place the buttons into the frame then you
- don't need to pick the size of the frame yourself: the packer will set
- the frame's size itself so that it's just large enough to contain all the
- information you've packed into it.
-
- If for some reason you want to know how much space a button (or any other
- window) wants, you can always use "winfo reqheight" and "winfo reqwidth"
- to get that. However this shouldn't be necessary in your case, unless I'm
- missing something.
-