Table Of Contents

Previous topic

Focus

Next topic

Styling

Position and Size

All positions and sizes refer to the parent widget (except for GUI, that has no parent). Both, position and size, are tuples of two values. These values can be absolute amounts of pixles or relative amounts on a percentage basis refering to the parent size. They are independently, ie. the height can be absolute while the width is relative.

Generally, you should not use absolute values (size and position) if the parent size is relative. But if so, use min_size. Otherwise your widgets may become bigger than the parent and that will cause display errors.

Position

The Position of a widget depends on its size, its anchor and the position of its parent. The last one is the origin for the calculation. The own position is just an offset to this point. This is important when you manually set the position of a widget and for internal use. If you need to know the current position of the widget, the pos attribute will give you the current topleft position of the widget as absolute pixel values from the topleft of the screen. Thus, you can use this value to blit your widget. The same applies to the rect attribute, that is a readonly version of the current rect of the widget. If you move the widget with move, the position units will not be changed. That means if you have a relatively positioned widget and move it 20 pixels to the right, the new position will still be relative. This is very useful, if you want to let the user change the (relative) position (ie. move a widget).

Size

The size is similar to the position, but a bit easier. Its just an absolute value or a relative amount of the parent size. Like the position, the units will not change if you use the resize method.

Inner Rects

Todo

Write inner rect documentation here.

_images/positioning.png

Example of positioned Widget