| | 10 | |
| | 11 | The topmost widget ''(a)'' is rendered the full size of the |
| | 12 | screen. ''(a)'' then renders ''(b)'', ''(b)'' renders ''(c)'' |
| | 13 | and so on. |
| | 14 | |
| | 15 | When a widget renders its contained widgets it chooses the size |
| | 16 | and position of each contained widget. For example, widget |
| | 17 | ''(b)'' is responsible for the layout of ''(c)'', ''(d)'' and |
| | 18 | ''(e)''. |
| | 19 | |
| | 20 | == Box, Flow and Fixed Widgets == |
| | 21 | |
| | 22 | The size of a widget is measured in screen columns and rows. |
| | 23 | Widgets that are given an exact number of screen columns and |
| | 24 | rows are called box widgets. The topmost widget is always |
| | 25 | a box widget. |
| | 26 | |
| | 27 | Much of the information displayed in a console user interface |
| | 28 | is text and the best way to display text is to have it flow |
| | 29 | from one screen row to the next. Widgets like this that |
| | 30 | require a variable number of screen rows are called flow widgets. |
| | 31 | Flow widgets are given a number of screen columns and can |
| | 32 | calculate how many screen rows they need. |
| | 33 | |
| | 34 | Occasionally it is also useful to have a widget that knows |
| | 35 | how many screen columns and rows it requires, regardless of |
| | 36 | the space available. This is called a fixed widget. |
| | 37 | |
| | 38 | It is an Urwid convention to |
| | 39 | use the variables `maxcol` and `maxrow` to store a widget's |
| | 40 | size. Box widgets use the tuple `(maxcol, maxrow)` in |
| | 41 | the signature of functions that are passed a size. |
| | 42 | Flow widgets use the single-element tuple `(maxcol,)` instead |
| | 43 | because they calculate their `maxrow` based on the `maxcol` |
| | 44 | value. Fixed widgets expect the value `None` to be passed in |
| | 45 | to functions that take a size because they know their `maxcol` |
| | 46 | and `maxrow` values. |
| | 47 | |
| | 48 | |