Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Widget's height relative to other widget's height

Status
Not open for further replies.

papageno

Technical User
Dec 25, 2004
24
0
0
ES
I have this code:

frame .aframe
label .aframe.label1 etc...
text .aframe.text etc...
label .aframe.label2 etc...
pack .aframe.label1 .aframe.text .aframe.label2 -side left
pack .aframe -side top

How can I make it so that the labels' height is proportional to the text widget's height?
 
In what sense "proportional"? Do you want the font of the label to be equal in height to the number of rows in the text?

You can limit the number of rows in the text with "-height 5", say for 5 rows, in the definition statement. You can set the font of the label, including the size with something like, "-font {courier 9}".

Bob Rashkin
rrashkin@csc.com
 
I mean the 'box' (using a CSS term), I want the three 'boxes' to have the same height, which has to be the height of the text's 'box'. The labels won't contain text, but an image.
 
In that case, the -height option should be used for the label:
Specifies a desired height for the label. If an image or bitmap is being displayed in the label then the value is in screen units (i.e. any of the forms acceptable to Tk_GetPixels); for text it is in lines of text. If this option isn't specified, the label's desired height is computed from the size of the image or bitmap or text being displayed in it.

You'll have to derive a proportionality constant which will be dependent on the system's local configuration.

Bob Rashkin
rrashkin@csc.com
 
All right, since I wanted the image to occupy the whole of the labels, here's what I did:

Code:
frame .aframe
label .aframe.label1 etc...
text .aframe.text etc...
label .aframe.label2 etc...
pack .aframe.label1 .aframe.text .aframe.label2 -side left
pack .aframe -side top

set textheight [winfo reqheight .aframe.text]
image create photo bgimg -file bgimg.gif -height $textheight
.aframe.label1 configure -image bgimg
.aframe.label2 configure -image bgimg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top