peng3d.gui.layout - Layout Helper Classes

class peng3d.gui.layout.Layout(peng, parent)[source]

Base Layout class.

This class does not serve any purpose directly other than to be a common base class for all layouts.

Note that layouts can be nested, e.g. usually the first layouts parent is a SubMenu and sub-layouts get a LayoutCell of their parent layout as their parent.

class peng3d.gui.layout.GridLayout(peng, parent, res, border)[source]

Grid-based layout helper class.

This class provides a grid-like layout to its sub-widgets. A border between widgets can be defined. Additionally, all widgets using this layout should automatically scale with screen size.

cell_size

Helper property defining the current size of cells in both x and y axis.

Returns:2-tuple of float
get_cell(pos, size, anchor_x='left', anchor_y='bottom', border=1)[source]

Returns a grid cell suitable for use as the pos parameter of any widget.

The size parameter of the widget will automatically be overwritten.

Parameters:
  • pos – Grid position, in cell
  • size – Size, in cells
  • anchor_x – either left, center or right
  • anchor_y – either bottom, center or top
Returns:

LayoutCell subclass

class peng3d.gui.layout.LayoutCell[source]

Base Layout Cell.

Not to be used directly. Usually subclasses of this class are returned by layouts.

Instances can be passed to Widgets as the pos argument. The size argument will be automatically overridden.

Note that manually setting size will override the size set by the layout cell, though the position will be kept.

pos

Property accessing the position of the cell.

This usually refers to the bottom-left corner, but may change depending on arguments passed during creation.

Note that results can be floats.

Returns:2-tuple of (x,y)
size

Property accessing the size of the cell.

Note that results can be floats.

Returns:2-tuple of (width, height)