GRIDPLUS has facilities to control the resizing behaviour of windows.
By default, GRIDPLUS creates a window with the minimum size neccessary to contain the required
widgets with the requested sizes. Resizing this (as it stands) is unlikely to produce the desired
result. In partucular, resizing the window to a smaller size is likely to result in a very messy
display. To see the result, enable resizing by putting "wm resizable . 1 1" at the begining
of your application. Then try resizing, both larger and smaller. The result is probably not very pretty.
To make resizing work properly, additional work is required to specify what is to happen to the widget positions
and sizes when the window is resized. Starting with release 2.4, GRIDPLUS has new layout
options and a new gridplus pack command for this purpose.
Many window layouts do not lend themselves to useful resizing, but those with text,
tree and tablelist are most likely to benefit from
resizing.
Note: The gridplus pack command must be used (rather than the normal Tk pack command)
when a GRIDPLUS created window is to be resizable.
GRIDPLUS Layout Resizing Options
|
Each layout cell may optionally have a
delimited sticky indicator, n, s, e, w (Default)
or c (Centre). The sticky delimeter may be ":", "=", "|"
or "+".
For non-resizable windows the colon (":") delimeter is used. The other options are available
to control the grid weight for
applications which have resizable windows. Generally "=" should be used for grid cells
which are to be resized horizontally, "|" for vertical resizing and "+" for both
horizontal and vertical resizing. For text and tree items, where it is required that the item
increases/decreases in size as the widow is resized the colon (":") delimeter should be
used. The delimiters may also be used on their own (without a sticky indicator) where required
(See the Example below).
These rules are not absolute, but should be used as a starting point.
This section contains an example which illustrates the GRIDPLUS resizing facility features.
The following example assumes that the reader is familiar with the contents of the
Grid/Layout, Button, Tree,
Text and Entry pages. Information given on those pages
will not be duplicated here.
The comments below concentrate on the Layout weighting options and
the GRIDPLUS pack command mode.
Note: The example assumes that the GRIDPLUS package has already been "required" and the
commands imported.
Resize Example
Resizing Behaviour Required:
- ".toolbar" is to be anchored to the lefthand side. The space above/below the toobar is not to
expand when the window is resized.
- ".mytree" is to expand in both X and Y directions.
- ".mytext" is to expand in the Y direction only. Its X direction size is
set by the size of ".myentry1".
- ".myentry1" is not to resize. The space around around the grid is to expand
when the window is resized.
- ".myentry2" and ".mybutton" are to stretch in the X direction when the
window is resized. The space above/below each is not to expand when the window is resized.
Window:
Resized...
Source Code:
gridplus button .toolbar -style Toolbutton -space 0 -padding {0 0 0 0} {
{.back :navback22} {.home :navhome22} {.forward :navforward22}
}
gridplus tree .mytree -width 100 -height 15 -scroll y -title "Tree"
gridplus text .mytext -width 35 -height 10 -scroll xy -title "Text"
gridplus entry .myentry1 -width 30 -title "Entry Grid One" {
{"Entry One" .entry1}
{"Entry Two" .entry2}
{"Entry Three" .entry3}
}
gridplus entry .myentry2 -title "Entry Grid Two" {
{"Entry One" .entry1} {"Entry Four" .entry4} {"Entry Seven" .entry7}
{"Entry Two" .entry2} {"Entry Five" .entry5} {"Entry Eight" .entry8}
{"Entry Three" .entry3} {"Entry Six" .entry6} {"Entry Nine" .entry9}
}
gridplus button .mybutton {
{"Button One" .button1} {"Button Two" .button2}
}
gridplus layout .main -wtitle "Resize Example" {
.toolbar=w -
= -
.mytree:nsew .mytext:nsew
^ .myentry1+
.myentry2=ew -
= -
.mybutton=ew -
}
gridplus pack .main -resize xy
Comments:
-
gridplus layout .main -wtitle "Resize Example" {
.toolbar=w -
= -
.mytree:nsew .mytext:nsew
^ .myentry1+
.myentry2=ew -
= -
.mybutton=ew -
}
- Creates a layout called ".main". ".toobar",".mentry2" and ".mybutton"
(which are to resize in the X direction only) use the "=" sticky delimeter. This stops the space expanding
above/below the grids when the window is resized.
As a general rule, where text, tree and tablelist widgets are to be resizeable, use the ":nsew" sticky
delimeter/indicators.
The "+" sticky delimiter (here used without any sticky indicators) stops the space left/right/above/below
the grid expanding when the window is resized.
-
gridplus pack .main -resize xy
- Packs the ".main" layout and specifies that the window may be resized in both the X and Y directions.
By default the gridplus pack command will not allow the window to resized smaller
than its creation size. See Example 7 for a sample of an application which allows
the window to be resized smaller than its creation size.
-
As an example of how the use of the sticky delimiters effects the look of the window when it
is resized, the example below uses the ":" delimiter only.
gridplus layout .main -wtitle "Resize Example" {
.toolbar:w -
= -
.mytree:nsew .mytext:nsew
^ .myentry1
.myentry2:ew -
= -
.mybutton:ew -
}
When resized...
Copyright © 2014 Adrian Davis.