devctrl.gui.utility.screen_size.constrain_to_screen#
- constrain_to_screen(size_hint: QSize, min_width: int, min_height: int, max_width_fraction: float = 0.5, max_height_fraction: float = 0.7) QSize[source]#
Return a QSize constrained by: 1. The widget’s sizeHint (ideal size) 2. A minimum size (min_size) 3. A maximum percentage of the screen resolution (default: 50% width, 70% height)
- Parameters:
size_hint – The widget’s preferred size (e.g., widget.sizeHint()).
min_width – The smallest allowed width.
min_height – The smallest allowed height.
max_width_fraction – Max width as a fraction of screen width.
max_height_fraction – Max height as a fraction of screen height.
- Returns:
QSize that fits all constraints.