Navigation Logo 12.2  Size Navigation Logo

 

 

The common size options are -width and -height. The widgets whose size you will want to control are, for the most part, the widgets that do not contain other widgets.

A part of the geometry management process is to determine a master widget's desired size from the declared or desired sizes of its slaves. This is why you usually control size by using the size options on those slaves which are not also masters.

The desired size of a master widget is not necessarily the size the widget gets. As you create your first windows, you should try to resize them with your mouse so you can get used to what happens. User resizing is only one thing that can cause a geometry manager to override a master widget's desired size.

Size options are measured in one of two ways:

characters
If the widget is concerned with text, then distance is measured by counting the number of characters. For calculating width, an average character width for the font is used. For calculating height, the size allocated to a line is used.

screen distance
If the widget is not concerned with characters, then there are several units that can be used to declare screen distances.

The usual screen distance measurement is a count of pixels. That is the unit Tk uses unless you declare another with one of these suffixes:

...i
inches

...c
centimeters

...m
millimeters

...p
printers' points

Tk expects a nonnegative integer either by itself for a count of pixels or with one of these suffixes for a measurement of the indicated kind.

Choose the unit which fits your needs but see the discussion above in Multiplatform Caveat.

Some widgets will accept measurements in either characters or screen distances – depending on how they are configured. Buttons are this way, you can label them with a character string or with an image. The units you use for a size option will be characters when the label is a character string and screen distances when the label is an image.

 

 

[Sample TK Application]
Author's Home Page
Navigation Logo [Book's Cover]
Order from Amazon.