size

Classes used for calculating widget size.

SizeResolver

class tanmatsu.size.SizeResolver

Abstract base class. Used in tanmatsu.widgets.Widget and descendants for calculating widget size.

abstract min(parent_size: int) int

Return the minimum possible size resolve() could resolve to, given the parent’s size.

abstract max(parent_size: int) int

Return the maximum possible size resolve() could resolve to, given the parent’s size.

abstract resolve(parent_size: int, requested_size: int) int

Resolve the actual size we request to be allocated by the parent widget, given the parent’s size and the size the parent requests of us.

We can choose to handshake the parent’s requested size or not. The parent widget has the final say on how much it actually allocates.

Parameters
  • parent_size (int) – The size of the parent.

  • requested_size (int) – The size the parent requests of us.

FixedInteger

class tanmatsu.size.FixedInteger(actual: int)

Always resolve to a fixed sized.

Parameters

actual (int) – A size, in rows/columns.

min(parent_size: int) int

Return the minimum possible size resolve() could resolve to, given the parent’s size.

max(parent_size: int) int

Return the maximum possible size resolve() could resolve to, given the parent’s size.

resolve(parent_size: int, requested_size: int) int

Resolve the actual size we request to be allocated by the parent widget, given the parent’s size and the size the parent requests of us.

We can choose to handshake the parent’s requested size or not. The parent widget has the final say on how much it actually allocates.

Parameters
  • parent_size (int) – The size of the parent.

  • requested_size (int) – The size the parent requests of us.

ParentRequested

class tanmatsu.size.ParentRequested

Always resolve to the parent’s requested size.

min(parent_size: int) int

Return the minimum possible size resolve() could resolve to, given the parent’s size.

max(parent_size: int) int

Return the maximum possible size resolve() could resolve to, given the parent’s size.

resolve(parent_size: int, requested_size: int) int

Resolve the actual size we request to be allocated by the parent widget, given the parent’s size and the size the parent requests of us.

We can choose to handshake the parent’s requested size or not. The parent widget has the final say on how much it actually allocates.

Parameters
  • parent_size (int) – The size of the parent.

  • requested_size (int) – The size the parent requests of us.

ParentPercent

class tanmatsu.size.ParentPercent(actual: int)

Resolve to a percent of the parent’s size.

Parameters

actual (int) – An integer between 0 and 100.

min(parent_size: int) int

Return the minimum possible size resolve() could resolve to, given the parent’s size.

max(parent_size: int) int

Return the maximum possible size resolve() could resolve to, given the parent’s size.

resolve(parent_size: int, requested_size: int) int

Resolve the actual size we request to be allocated by the parent widget, given the parent’s size and the size the parent requests of us.

We can choose to handshake the parent’s requested size or not. The parent widget has the final say on how much it actually allocates.

Parameters
  • parent_size (int) – The size of the parent.

  • requested_size (int) – The size the parent requests of us.

Clamp

class tanmatsu.size.Clamp(minv: int, actual: int, maxv: int)

Resolve to the parent’s requested size, as long as it is between a set minimum and maximum. Otherwise, resolve to a percentage of the parent’s size, and clamp it between said minimum and maximum.

Parameters
  • minv (int) – The minimum size that this function will resolve to.

  • actual (int) – The percentage of the parent’s size that this function will resolve to, assuming the parent’s requested size is outside the bounds of the minimum and maximum size.

  • maxv (int) – The maximum size that this function will resolve to.

__init__(minv: int, actual: int, maxv: int)
min(parent_size: int) int

Return the minimum possible size resolve() could resolve to, given the parent’s size.

max(parent_size: int) int

Return the maximum possible size resolve() could resolve to, given the parent’s size.

resolve(parent_size: int, requested_size: int) int

Resolve the actual size we request to be allocated by the parent widget, given the parent’s size and the size the parent requests of us.

We can choose to handshake the parent’s requested size or not. The parent widget has the final say on how much it actually allocates.

Parameters
  • parent_size (int) – The size of the parent.

  • requested_size (int) – The size the parent requests of us.